<div id="yes">
<div class="wrapper">
<something>...</else>
<p>foobar</p>
</div>
</div>
I want to get the p-tag to append a classname
$("div.wrapper", "#yes").addClass("newClassName");
But where to add the "p"?
Try
$("div#yes > div.wrapper > p").addClass("newClassName");
Here is a jsFiddle demo
This can be achieved by the folowing code:
$("#yes div.wrapper p").addClass("newClassName");
This code gets any p-tag within any div with the class "wrapper" which is located in an element with the id "yes".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With