其他分享
首页 > 其他分享> > 过滤敏感词案例

过滤敏感词案例

作者:互联网

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

标签:btn,textarea,敏感,案例,过滤,let,querySelector,div,document
来源: https://blog.csdn.net/zhazhali_fenqi/article/details/122607938