Strip tags (with tags inside attributes and nested tags) using javascript

Posted by Kokizzu on Stack Overflow See other posts from Stack Overflow or by Kokizzu
Published on 2013-11-08T09:18:36Z Indexed on 2013/11/08 15:55 UTC
Read the original article Hit count: 381

Filed under:
|

What the fastest (in performance) way to strip strings from tags, most solution i've tried that uses regexp not resulting correct values for tags inside attributes (yes, i know it's wrong), example test case:

 var str = "<div data-content='yo! press this: <br/> <button type=\"button\"><i class=\"glyphicon glyphicon-disk\"></i> Save</button>' data-title='<div>this one for tooltips <div>seriously</div></div>'> this is the real content<div> with another nested</div></div>"

that should resulting:

 this is the real content with another nested

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about strip-tags