jquery - html 字符串未在 textarea 字段中正确填充
问题描述
我需要能够在 textarea 中呈现一些 HTML 标签(即 , , , ),但 textareas 仅将其内容解释为文本。预期的字符串如下
<strong><span style=""background-color: yellow"">I AGREE </span>TO THE TERMS AND CONDITIONS OF THE CONSUMER INSTALLMENT LOAN AGREEMENT (this “Contract”).<br>By electronically signing the Contract by checking the box above and then clicking the “Get Loan Now” button below, you (i) acknowledge receipt of this Contract, with all necessary spaces filled in, (ii) certify you fully read and understand the Contract and you agree to comply with and be bound by its terms, and (iii) you reaffirm consent to the use of electronic records for all transactions with LendNation and all documents relating to those transactions.</strong>
但它替换为下面
\u003cstrong\u003e\u003cspan style\u003d\"background-color: yellow\"\u003eI AGREE \u003c/span\u003e "TO THE TERMS OF THE VOLUNTARY ACH CREDIT AUTHORIZATION AGREEMENT(the "ACH Credit Authorization")".\u003c/strong\u003e\u003cbr\u003e "By electronically signing the ACH Credit Authorization by checking the box above and then clicking the "Get Loan Now" button below, you certify you fully read and understand the ACH Credit Authorization provision of the Contract, and you agree to comply with and be bound by its terms."\u003cbr/\u003e"
解决方案
这不能用 textarea 来完成,但看一下contenteditable
属性。
<div contenteditable="true">
This text can be edited by the <strong>user</strong>.
</div>
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content
推荐阅读
- esper - com.espertech.esper.schedule.ScheduleSlot 在 5.5.0 版本中
- python - PySpark Pipeline.fit(df) 方法给出 PicklingError: Could not serialize object: ValueError: substring not found while using Elephas
- excel - 如果单元格更改,清除内容离开公式
- sql - 有没有办法在没有联合的情况下组合列?
- bash - 如何使用“sed”shell命令来混淆某些字符指示的信息
- javascript - 有没有办法确定要在 javascript 数组中推送的值的数量?
- php - 上传图像时尝试访问 null 类型值的数组偏移量
- postgresql - 重新格式化输出查询行和列
- c# - 从 Excel 获取日期列值
- audio - 试图在 Swift 的信标区域中加入声音