Let’s see:
<div><p>this div contains a p tag</p></div>
<div>this one is not</div>
How do i assign a variable with a boolean value (true or false) if a div contains a specific tag like p in the above example?
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.
will add a class to all divs that contain p children. If the paragraphs aren’t direct children, this won’t pick them up.
Note: doing this:
will add the class to the paragraph not the div. You can fix that by doing this:
but this will catch multiple div ancestors. You could do this:
to fix that.
Or more programmatically: