The following two forms of jQuery selectors seem to do the same thing:
- $(‘div > ul.posts’)
- $(‘div ul.posts’)
which is to select all the ‘ul’ elements of class ‘posts’ under ‘div’ elements.
Is there any difference?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Concerning
$('div > ul.posts'), only direct descendants ofDIVs will be selected.while
$('div ul.posts')will select all descendants matching the criteria. So all and anyul.postswill be selected, whatever their nesting level is as long as somewhere along the chain, they are within adiv.