Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strip html tag which has an Id

Status
Not open for further replies.

hunt00

Technical User
Mar 6, 2005
79
0
0
US
How could i strip the html tag which relates to an ID.

For example:

<div id="testid" class="test"><p>This is the body</p></div>

How to strip the pair of <div> tag, that results only contains: <p>This is the body</p>

Thanks!
 
i love a challenge.

try this:

Code:
var str = "something<div id='testid' class='test'><p>This is the body</p></div><div>some other div</div><div id='testid' class='test'><p>This is the body</p></div>hahahah";
var re = /(.*?)(\<div\s+.*?id\s*\=.*?\>)(.*?)(\<\/div\>)(.*?)/gi;

var newstr = str.replace( re, "$1$3$5" );
alert( newstr );



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top