javascript - How can I remove tags using DOM? -
javascript - How can I remove <style> tags using DOM? -
i have variable contains html text web page. text includes style area different contents inside.
var myhtml = "xxxxx <style type="text/css"> .... css style definition area. yyyy" </style>
one way via dom;
var el = document.createelement("div"); el.innerhtml = html_string; var style = el.getelementsbytagname("style"); (var = style.length - 1; >= 0; i--) { style[i].parentnode.removechild(style[i]); } alert(el.innerhtml); javascript
Comments
Post a Comment