【问题标题】:jquery select element inside a classjquery选择类中的元素
【发布时间】:2010-04-20 04:28:03
【问题描述】:
我想在这样的 div 中选择一个锚点
<div class="response content">
Disapproved Bank Mandiri<br><br>
<p>
<a class="showlist" href="#">Back to list?</a>
</p>
</div>
执行此操作的 jquery 是什么?
【问题讨论】:
标签:
jquery
jquery-selectors
【解决方案1】:
div 中任何带有“response”和“content”类的锚点:
$('.response.content a')
或者只有“showlist”类的主播:
$('.response.content a.showlist')
【解决方案3】:
解决此问题的另一种方法是使用 jQuery .find()
这是一个使用 find() 选择 div 中具有“响应内容”类的所有元素的示例。
jQuery('.response.content').find('a');
这也是一篇访问selectors vs. .find()主题的有用帖子
【解决方案4】:
你可以使用:
$('.response').find('a');
或者
$('.response').find('.showlist');