HTML:
<div id='example'>
<p> First paragraph</p>
<p> Second paragraph</p>
<p> Third paragraph</p>
</div>
Javascript with JQuery:
var paragraphs = $('div#examples p');
This returns an array of HTMLParagraphElement objects. However, I wish to return Jquery objects. (So that I can use e.g:
for(i=0;i<paragraphs.length;i++)
{
paragraph[i].hide();
}
Is there a way I can easily do this? Thanks.
Description. "$("div p")" Selects all elements matched by <div> that contain an element matched by <p>.
Definition and Usage. The element selector can also be used to select multiple elements. Note: Seperate each element with a comma.
You can simply use the jQuery text() method to get all the text content inside an element. The text() method also return the text content of child elements.
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