var div = $(this), ul = $("ul", div), li = $("li", ul);
Please explain, what does this code do?
By steps.
Thanks.
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.
It ends up with these equivalents:
So it’s getting the current
<div>, any<ul>elements inside it, and any<li>elements inside those, and placing each collection in its own variable.When you do
$(selector, content)you’re actually doing$(context).find(selector)under the covers, so the code in your question is just chaining one call to the next, effectively doing a.find()inside each time.