Bootbox将DIV标签移到表格外

安迪·C

我正在使用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标签不再包裹表格了?

扎卡里亚·阿查尔基(Zakaria Acharki)

发生这种情况是因为将<div>标签直接放在标签内<table>不是有效的HTML结构,因此浏览器将自动纠正该错误,并通过将<div>标签从表中移出来返回有效表达式

希望这可以帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章