Thursday, 15 September 2011

javascript - JS - text value of tag - when tag is string -



javascript - JS - text value of tag - when tag is string -

how can text value of tag when tag stored string?

var value = "<div>teeext</div>";

tag can anything, attributes may contain ">" string well, regexp can unsafe - text value can tag.

you can create dummy element:

var value = "<div>teeext</div>"; var div = document.createelement('div'); div.innerhtml = value; var text = div.innertext || div.textcontent;

javascript regex dom

No comments:

Post a Comment