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

后端 未结 9 839
忘掉有多难
忘掉有多难 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:14

    UPDATE

    Use the following to strip tags while keeping content

    $('#text').find('p').contents().unwrap();
    

    This will strip p tag where p is a child element of '#text'.

    Check working example at http://jsfiddle.net/YWCsH/

提交回复
热议问题