如何使用html标签获取文本,但只能从主DIV获取文本?不形成其他DIVS。通过jquery获取来自主DIV的html标签的文本?
这里是例子,但有一些问题,becouse文字无需HTML标记< BR />
HTML
<div id='parent'>
this text is <br />for parent
<div id='child-parent'>
this text if for child-parent
<div id='child'>
and this text is for child.
</div>
</div>
</div>
jQuery的
alert($('#parent').clone().children().remove().end().html());
'$的.text()'返回没有标签的内容的字符串。 – Broxzier
@Broxzier - 他想要那些标签。 – tymeJV
你能解释一下你期望从这个例子中返回吗? – Broxzier