Home  >  Article  >  Web Front-end  >  How to remove js from html tag

How to remove js from html tag

小云云
小云云Original
2018-03-07 16:28:501930browse

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>

Java seems to be this Str.replaceAll("549a3fd9a3c62568d8b32cd8627105c3]*>","");

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;
}
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!

Statement:
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