Remove all HTMLtags in a string (with the jquery text() function)

后端 未结 6 1909
不思量自难忘°
不思量自难忘° 2020-12-03 06:44

is it possible to use the jquery text() function to remove all HTML in a string?

String with HTML tags:
myContent = \'

6条回答
  •  时光说笑
    2020-12-03 07:35

    Could you not just try it?

    myContent = '
    Hello world!
    '; console.log($(myContent).text()); //Prints "Hello world!"

    Note that you need to wrap the string in a jQuery object, otherwise it won't have a text method obviously.

提交回复
热议问题