jQuery (almost) equivalent of PHP's strip_tags()

后端 未结 9 824
忘掉有多难
忘掉有多难 2020-11-27 04:50

Is there a jQuery version of this function?

string strip_tags( string $str [, string $allowable_tags ] )

stri

9条回答
  •  隐瞒了意图╮
    2020-11-27 05:13

    Just use a regular expression:

    html.replace( /<.*?>/g, '' );
    

    Done. :)

    For the p tag:

    html.replace( /<[^p].*?>/g, '' );
    

    For other tags, it gets more complicated.

提交回复
热议问题