<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#msg{width: 400px; height: 400px; border: 1px solid black}
</style>
<script>
var arr = [/cao/ig,/靠/ig,/tm/ig];
function zanghua(){
var yuanwen = document.getElementById("txt1");
var wendang = document.getElementById("msg");
var value1 = yuanwen.value;
for (var i = 0 ; i < arr.length ; i++){
value1 = value1.replace(arr[i],"#");
}
wendang.innerHTML = value1;
yuanwen.value = '';
}
</script>
</head>
<body>
<textarea name = "" id = "txt1" cols = "30" rows="10"></textarea>
<button onclick = 'zanghua();'>过滤</button>
<div id = 'msg'></div>
</body>
</html>
简单脏话过滤
最新推荐文章于 2024-11-02 19:19:35 发布