jQuery get content between <div> tags

Viewed 165502

This'll probably be easy for someone:

var x = '<p>blah</p><div><a href="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=brd&FlightID=2997227&Page=&PluID=0&Pos=9088" target="_blank"><img src="http://bs.serving-sys.com/BurstingPipe/adServer.bs?cn=bsr&FlightID=2997227&Page=&PluID=0&Pos=9088" border=0 width=300 height=250></a></div>';

How do I extract only the portion between the div tags <div>I want this</div> Don't focus on the <a> tag as the content could be different inside the div.

9 Answers

This work for me

var content = '<p> demp text </p>';
$('#wordContent').html(content);
$('#wordContent').html($('#wordContent').text());
Related