例如,原件p将是:
<p>
<h1>I'm title</h1>
This is some descriptions.
<a class="classToExclude">The Link #1</a>
<a>The Link #2</a>
</p>
我只想$('p').html() 排除h1anda.classToExclude。
看起来像:
<p>
This is some descriptions.
<a>The Link #2</a>
</p>
仅供参考,当我使用选择器$('p').children().each()方法时,它只返回nodes下面的内容,而不是内部文本This is some descriptions。它不包括在内。所以我不能使用.children()选择器来循环。