Arj*_*Raj 4 html javascript jquery
这是我的HTML:
<div class="accor">
</div>
<div class="accordionContentTwoCol">
<p class="noEdit">
<div> name : </div>
</p>
<div>
Run Code Online (Sandbox Code Playgroud)
我需要找到accordionContentTwoColdiv的html内容(我只能访问accor).
如果我尝试在accordionContentTwoCol div中打印html,如下所示:
alert("html inside accordionContentTwoCol :"+$('.accor').next().html());
Run Code Online (Sandbox Code Playgroud)
它提供如下输出:

虽然HTML里面accordionContentTwoCol是:
<p class="noEdit">
<div> name : </div>
</p>
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
查找允许的包含关系的权威位置是HTML规范.例如,参见http://www.w3.org/TR/html4/sgml/dtd.html.它指定哪些元素是块元素,哪些元素是内联元素.对于这些列表,请搜索标记为"HTML内容模型"的部分.
对于P元素,它指定以下内容,表示P元素仅允许包含内联元素.
<!ELEMENT P - O (%inline;)* -- paragraph -->
Run Code Online (Sandbox Code Playgroud)
这与http://www.w3.org/TR/html401/struct/text.html#h-9.3.1一致,它说P元素"不能包含块级元素(包括P本身)."
| 归档时间: |
|
| 查看次数: |
992 次 |
| 最近记录: |