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.
This is probably what you need:
$('div').html();demo
This says get the
divand return all the contents inside it. See more here: http://api.jquery.com/html/If you had many
divs on the page and needed to target just one, you could set anidon thedivand call it like so$('#whatever').html();where whatever is the
idEDIT
Now that you have clarified your question re this being a string, here is a way to do it with vanilla js:
Demo Here
divoccurs