我正在使用Bootbox显示模式。
使用JS,我正在创建一个字符串作为消息:
display = "<b>Notes</b>";
display += "<br><br>";
display += "<table class='table' id='notes-table'>";
display += "<div>";
display += "<tr><td>";
display += "...";
display += "</td></tr>";
display += "</div>";
display += "</table>";
然后我将其称为模式:
bootbox.alert( {
message: display,
buttons: {
ok: {
label: 'Close'
}
}
//Example.show("Hello world callback");
});
登录display
控制台,我得到:
<b>Notes</b><br><br><table class='table' id='notes-table'><div><tr><td>...</td></tr></div></table>
但是,当我检查DOM时,会得到:
<b>Notes</b>
<br>
<br>
<div></div>
<table class='table' id='notes-table'>
<tbody>
<tr>
<td>...</td>
</tr>
</tbody>
</table>
为什么DIV
标签不再包裹表格了?
发生这种情况是因为将<div>
标签直接放在标签内<table>
不是有效的HTML结构,因此浏览器将自动纠正该错误,并通过将<div>
标签从表中移出来返回有效表达式。
希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句