Html:
<div id="a">
<span></span>
<img />
</div>
jQuery:
var a = $("#a").children().find("img");
its showing a.length = 0. Whats the problem here?
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.
Use this:
findsearches for descendant of the selectors, and<img>isn’t a descendant of any of<div id="a"> direct childrens.finddocs:Live DEMO
Note that you can get the same result with more efficient selector:
descendantselector docs:Live DEMO