How can I get a sub element from $(this)?
So for example, how would I target a span element within the this object?
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.
You could use the
findmethod:That will find all
spanelements that are descendants of the element referred to bythis.If you only care about direct children you could use
childreninstead:Alternatively, you could use
thisas the context to a selector:Yet another solution would be required if
thiswas a jQuery object that contained a set of sibling elements (so thespanis not a descendant). In that case, you would needfilter: