Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse HTML with jquery

Tags:

jquery

suppose in a variable html is saved like

var vhtm="<div><div id='test'>zebra</div><div id='foo'>here is my many other html content</div></div>";

i want to parse the above html stored in variable with the help of jquery. i need to extract a particular div by id and including its content. the return result would like

<div id='foo'>here is my many other html content</div>

so i need to find div by id like id='foo'

please help me how to parse the above like jquery.

like image 602
Thomas Avatar asked Mar 23 '26 08:03

Thomas


1 Answers

try something like this :

$(vhtml).find('#foo');
like image 184
gion_13 Avatar answered Mar 24 '26 23:03

gion_13



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!