我有一个方法,它从数据库返回一个持久化的html模板。
模板的格式如下:
<div id="item_collection">
<div id="item_x">
<p id="item_x_headline"><h2>Some Headline</h2></p>
<p id="item_x_excerpt>Some text here</p>
</div>
<div id="item_x+1">
<p id="item_x+1_headline"><h1>Some Headline</h1></p>
<p id="item_x+1_excerpt>Some text here</p>
</div>
...and so on.
</div>
但是,在运行以下操作之后:
alert(data); //check that the template is in order. It Is.
$('#template_area').html(data);
HTML现在是:
<div id="item_collection">
<div id="item_x">
<p id="item_x_headline"></p> <!--Note The Lack of Nesting -->
<h2>Some Headline</h2>
<p id="item_x_excerpt>Some text here</p>
</div>
<div id="item_x+1">
<p id="item_x+1_headline"></p> <!--Note The Lack of Nesting -->
<h1>Some Headline</h1>
<p id="item_x+1_excerpt>Some text here</p>
</div>
...and so on.
</div>
那又是怎么回事?是否有更好的方法来替换空模板?
发布于 2018-08-03 09:28:16
<h2>
标记不是有效的子标记<p>
发布于 2018-08-03 10:25:15
https://stackoverflow.com/questions/-100000491
复制相似问题