过滤敏感词案例

<!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>
</head>

<body>
    <textarea name="" id="" cols="30" rows="10"></textarea>
    <button>发布</button>
    <div></div>
    <script>
        let btn = document.querySelector('button')
        let textarea = document.querySelector('textarea')
        let div = document.querySelector('div')
        btn.addEventListener('click', function () {
            div.innerHTML = textarea.value.replace(/激情|基情/g, '**')
            // div.innerHTML = textarea.value
        })
    </script>
</body>

</html>
上一篇:JVM内存区域(运行时数据区)划分


下一篇:用原生JS读写CSS样式的方法总结(1)