Home>Article>Web Front-end> How to remove tags in javascript
How to remove tags in javascript: First create a corresponding code file; then remove all html tags through the "function delHtmlTag(str){...}" method.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to remove tags in javascript
js regular matching (remove html tags)
Get the link address on the webpage:
string matchString = @"]+href=\s*(?:'(?^']+)'|""(? [^""]+)""|(? [^>\s]+))\s*[^>]*>";
Get the title of the webpage:
string matchString = @"(? .*) ";
Remove all html tags in the web page:
string temp = Regex.Replace(html, "<[^>]*>", ""); //html是一个要去除html标记的文档
string matchString = @"([\S\s\t]*?) ";
js function to remove all html tags:
function delHtmlTag(str) { return str.replace(/<[^>]+>/g,"");//去掉所有的html标记 }
Count word count
t = $('.remarktext').html().replace(/<[^>]+>/g,"").length;
[Recommendation:javascript advanced tutorial】
The above is the detailed content of How to remove tags in javascript. For more information, please follow other related articles on the PHP Chinese website!