jQuery selector inside the each() method

后端 未结 5 1552
暗喜
暗喜 2020-12-31 12:32

Lets say that I have a HTML that looks like this:

1
2
5条回答
  •  情深已故
    2020-12-31 12:39

    easiest way is this, if you want all the elements

    $('.aaa span');
    

    jquery can nest selectors just like css can. also, if for some reason you need to loop

    $('.aaa').each(function(){
        x = $(this).find('span');
    });
    

    that will set x as the elements as a jquery object.

提交回复
热议问题