如何将大的 HTML 标签嵌入到这个场景中?
$(document).ready(function () {
window.showim = function(src) {
$("#divcont1").html(src);
};
});
而不是 <h1>test</h1>
我需要插入大的 html 内容
<span class="spcusr" onclick="showim('<h1>test</h1>');">click me</span>
<div id="divcont1"></div>
我的大型 HTML 内容示例
<div style="width:976px; height:576px; overflow:hidden; background-repeat:no-repeat; background-image:url(MASTER.jpg)">
<table style="cursor:pointer;">
<tr height="144">
<td width="485" onclick="window.location='#';"> </td>
<td width="485" onclick="window.location='#';"> </td>
</tr>
<tr height="144">
<td onclick="window.location='#';"> </td>
<td onclick="window.location='#';"> </td>
</tr>
<tr height="144">
<td onclick="window.location='#';"> </td>
<td onclick="window.location='#';"> </td>
</tr>
<tr height="144">
<td onclick="window.location='#';"> </td>
<td onclick="window.location='#';"> </td>
</tr>
</table>
</div>
我的主要问题是双引号和引号。因为 onclick="showim(' this started with single quotes and no more quotes allowed inside
')";那么,遇到这种情况怎么办?谢谢
最佳答案
你必须转义比 "和 ' 更深的引号。
这里,可能对你有帮助: Escape quotes in JavaScript
关于javascript - HTML 内容中的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21432203/