开发者

jquery select element inside a class

开发者 https://www.devze.com 2022-12-27 05:49 出处:网络
I want to select an anchor inside a div like this <div class开发者_如何学C=\"response content\">

I want to select an anchor inside a div like this

<div class开发者_如何学C="response content">
  Disapproved Bank Mandiri<br><br>
  <p>
    <a class="showlist" href="#">Back to list?</a>
  </p>
</div>

What is the jquery to do this ?


Any anchor in a div with "response" and "content" classes:

$('.response.content a')

Or only anchors with a class of "showlist":

$('.response.content a.showlist')


If you require both classes on the DIV:

$("div.response.content a.showlist");

If not,

$("div.response a.showlist");

To learn more about basic usage of jQuery Selectors, visit http://api.jquery.com/category/selectors/


Another way you could solve this is using jQuery .find()

Here is an example of using find() to select all elements in a div with the class "response content".

jQuery('.response.content').find('a');

This is also a helpful post that visits the topic of selectors vs. .find()


You can use :

$('.response').find('a');

Or

$('.response').find('.showlist');
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号