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

后端 未结 6 1910
不思量自难忘°
不思量自难忘° 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 07:13

    I created this test case: http://jsfiddle.net/ccQnK/1/ , I used the Javascript replace function with regular expressions to get the results that you want.

    $(document).ready(function() {
        var myContent = '
    Hello world!
    '; alert(myContent.replace(/(<([^>]+)>)/ig,"")); });

提交回复
热议问题