如何在Javascript中将字符串值从变量转换为HTML
How to convert string values from variable to HTML in Javascript
如何在Javascript中将字符串值更改为HTML
问题
我的表单将HTML代码呈现为字符串,我没有控件。
它是动态渲染的。
现在我需要更改字符串内容以呈现为HTML
我在var中有以下值,检查作为字符串
var checking = formEl.innerHTML;
var检查中的字符串值是
<thead id="updateContent">
<tr>
<th style="width:25%" class="spacingInHeader">Years of Expierence </th>
<th style="width:50%" class="spacingInHeader">Salary</th>
<th style="width:25%" class="spacingInHeader">Actions</th>
<input type="hidden" id="editRowIndex" value="">
</tr>
</thead>
<tbody>
<tr id="divUserList">
<td class="dynamicRow"> <input style="width:100px!important;" type="text" id="totalExperience"> </td>
<td class="dynamicRow"> <input type="text" id="salaryForThisPosition"> </td>
</tr>
<tr id="alf-id29">
<td style="border-top-width: 1px; border-top-style: solid; border-top-color: rgb(197, 197, 197);">1</td>
<td style="border-top-width: 1px; border-top-style: solid; border-top-color: rgb(197, 197, 197);">1</td>
<td style="border-top-width: 1px; border-top-style: solid; border-top-color: rgb(197, 197, 197);"><a class="addLink" style="margin-right:10px" href="#" onclick="javascript:editRow(this);return false;"> Edit </a> <a href="#" class="addLink" onclick="javascript:deleteRow(this);return false;"> Delete </a> </td>
</tr>
</tbody>
我想将这些字符串值呈现为HTML
更多解释
我在检查变量中有值
在该字符串值中,我有一个idupdateContent,我想将这些字符串值呈现为HTML
我有什么办法可以做到这一点吗。
提前谢谢。
将您想要更改的html放入另一个div中。并更改该div的内部html
例如,如果我们有一个非常简单的代码:
<p>Hello~!</p>
你想用html来自由修改它说。。。
<h1>Goodbye?!</h1>
你做的很简单:你把它放在一个类似这样的div中:
<div id="myName"><p>Hello~!</p></div>
您可以在javascript:中执行此操作
document.getElementById("myName").innerHTML = "<h1>Goodbye?!</h1>"
那。。。真的!
Js为那些想要检查的人出价:https://jsfiddle.net/9az241sf/
相关文章:
- 将标量变量转换为javascript中包含变量的数组
- 使用Javascript将多行变量转换为单行变量
- 变量转换为另一个“未定义”的变量
- 如何在javascript中将String变量转换为int
- 提交时将JavaScript变量转换为PHP表单
- 在d3.js中将局部变量转换为全局变量
- 在php函数中将php变量转换为javascript变量
- AngularJS变量转换为html<对象>属性
- 正在将字符串变量转换为数组
- 将变量转换为 json 路径
- 将 MVC 4 Razor 变量转换为 JavaScript 数组
- 如何在 JavaScript 中将局部变量转换为全局变量
- 如何将 jstl/JSP 变量转换为 JavaScript 变量
- 如何将变量转换为对象
- 如何使用 Javascript 将变量转换为字符串
- 在将会话变量转换为 javascript 变量时丢失特殊字符
- 如何在函数内将未定义的变量转换为对象
- 在按键和鼠标单击后将函数变量转换为全局变量
- 如何在javascript中将整数变量转换为字符串
- Javascript变量转换为Applescript