How to remove only html tags in a string using javascript

后端 未结 6 1385
臣服心动
臣服心动 2021-02-02 03:49

I want to remove html tags from given string using javascript. I looked into current approaches but there are some unsolved problems occured with them.

Current solutions

6条回答
  •  自闭症患者
    2021-02-02 04:06

    Here is my solution ,

    function removeTags(){
        var txt = document.getElementById('myString').value;
        var rex = /(<([^>]+)>)/ig;
        alert(txt.replace(rex , ""));
    
    }
    

提交回复
热议问题