jquery选择一个类中的元素

str*_*oir 34 jquery jquery-selectors

我想在这样的div中选择一个锚点

<div class="response content">
  Disapproved Bank Mandiri<br><br>
  <p>
    <a class="showlist" href="#">Back to list?</a>
  </p>
</div>
Run Code Online (Sandbox Code Playgroud)

什么是jquery这样做?

awg*_*wgy 49

具有"响应"和"内容"类的div中的任何锚点:

$('.response.content a')
Run Code Online (Sandbox Code Playgroud)

或者只有具有"showlist"类别的锚点:

$('.response.content a.showlist')
Run Code Online (Sandbox Code Playgroud)


Sam*_*son 11

如果您需要以下两个课程DIV:

$("div.response.content a.showlist");
Run Code Online (Sandbox Code Playgroud)

如果不,

$("div.response a.showlist");
Run Code Online (Sandbox Code Playgroud)

要了解有关jQuery选择器基本用法的更多信息,请访问http://api.jquery.com/category/selectors/