【发布时间】:2013-09-08 08:15:06
【问题描述】:
粗略的 HTML 结构:
<div class="wrapper">
<p></p>
<p></p>
<p></p>
</div>
<div class="wrapper">
<p></p>
<p></p>
<p></p>
</div>
<div class="wrapper">
<p></p>
<p></p>
<p></p>
</div>
假设我有这样的功能:
$('div.wrapper').each(function() {
// more stuff
});
我基本上想做这样的事情:
$(this).('p:eq(2)').remove();
或
$(this).('p:contains("old text")').text('new text');
以$(this)开头我只想选择其中的子元素。
【问题讨论】:
-
像
$('p', this)一样使用它作为上下文,或者像$(this).find('p')一样使用find()
标签: jquery dom jquery-selectors this