Home > Web Front-end > JS Tutorial > body text

How to remove js from html tag

小云云
Release: 2018-03-07 16:28:50
Original
1938 people have browsed it

This article mainly shares with you how to remove the js method of html tags. I hope it can help you learn how to remove js of html tags.

<script>
	function delHtmlTag(str){
		return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
	}
var str = "<span style=&#39;display:none;&#39;>This is test</span><img src=&#39;&#39;>ss</img><strong></strong><br/>";
str = delHtmlTag(str);
alert(str);
</script>
Copy after login

Java seems to be this Str.replaceAll("<[^>]*>","");

The modification made to the html tag for a title:

function delHtmlTag(str, obj){  
	var title = str.replace(/<[^>]+>/g,"");//去掉所有的html标记
	if(title.length > 300) {
		title = title.substring(0,300);
	}
	obj.title = title;
}
Copy after login
rrree

The above is the detailed content of How to remove js from html tag. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template