<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>从html中提取文本</title>
<style type="text/css">
textarea{
width: 400px;
height: 200px;
}
input{
margin-top: 20px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<h1>从html中提取文本</h1>
<hr />
<textarea id="first"></textarea><br />
<input type="button" value="替换" οnclick="filter()"/><br />
<textarea id="late"></textarea>
<script type="text/javascript">
function filter(){
// 取出要替换的值
var str = document.getElementById("first").value;
//定义正则
var reg = /<[^>]+>/g;
document.getElementById("late").value = str.replace(reg,"");
}
</script>
</body>
</html>
从html中提取文本 js
最新推荐文章于 2024-06-14 16:57:47 发布