<p>点击按钮修改图片的颜色为黑白 (100% 灰度)。</p> <button onclick="myFunction()">尝试一下</button><br> <img id="myImg" src="/upload2/attachments/cover/cover_css3.jpeg" alt="Pineapple" width="300" height="300"> <p><strong> 注意:</strong> IE 或 Firefox 浏览器不支持该属性。</p> <script> function myFunction() { document.getElementById("myImg").style.WebkitFilter = "grayscale(100%)"; // Chrome, Safari, and Opera } </script>