菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>小鸟启蒙(facesoho.com)</title> </head> <body> <p>点击按钮修改图片为黑白色(100% 灰色)。</p> <button onclick="myFunction()">点我</button><br> <img id="myImg" src="pineapple.jpg" alt="Pineapple" width="300" height="300"> <p><strong>注意:</strong> Internet Explorer 或 Safari 5.1 (及更早版本) 不支持该属性。</p> <script> function myFunction() { document.getElementById("myImg").style.WebkitFilter = "grayscale(100%)"; // Chrome, Safari, 和 Opera } </script> </body> </html>
运行结果