How to strip HTML tags from div content using Javascript/jQuery?

前端 未结 6 885
梦毁少年i
梦毁少年i 2020-12-31 22:24

I had made one div tag and stored its contents in a variable. If this tag contains p,b or any other tags then it should be removed from string. How

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 22:53

    This is safer:

    function plaintext(html){
      return $("
    ").html(html).text(); }

提交回复
热议问题