<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
#msg{
width: 400px;
height: 400px;
border: 1px solid;
}
</style>
<script>
var arr = [/靠/ig,/fuck/ig,/nmd/ig,/你妈的/ig];
function btnclick(){
var oTxt = document.getElementById("txt1");
var oMag = document.getElementById("msg");
var tihuan =oTxt.value;
for (var i = 0; i<arr.length; i++)
{
tihuan = tihuan.replace(arr[i],"**");
}
oMag.innerHTML = tihuan;
oTxt.value =‘‘;
}
</script>
<body>
<textarea name="" id="txt1" cols="30" rows="10"></textarea>
<div id="msg"></div>
<button onclick="btnclick()">提交</button>
</body>
</html>