<script type="text/javascript">
$(document).ready(function(){
console.log($('#list_table_template').html());
});
</script>
<div id="list_table_template" style="display: none;">
<table id="list_table" cellpadding="0" cellspacing="0">
<p>123</p>
<tr id="lt_header">
<!--#lt_header#-->
</tr>
<!--#lt_listing#-->
<tr id="lt_footer">
<td colspan="5">Footer Placeholder</td>
</tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
此代码未返回预期结果.
虽然我期待日志显示:
<table id="list_table" cellpadding="0" cellspacing="0">
<p>123</p>
<tr id="lt_header">
<!--#lt_header#-->
</tr>
<!--#lt_listing#-->
<tr id="lt_footer">
<td colspan="5">Footer Placeholder</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
但相反它给了我:
<p>123</p><table id="list_table" cellpadding="0" cellspacing="0">
<tbody><tr id="lt_header">
<!--#lt_header#-->
</tr>
<!--#lt_listing#-->
<tr id="lt_footer">
<td colspan="5">Footer Placeholder</td>
</tr>
</tbody></table>
Run Code Online (Sandbox Code Playgroud)
请注意,p标签出现故障并跳到表格前面.