运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to change the color of the image to black and white (100% gray).</p> <button onclick="myFunction()">Try it</button><br><br> <img id="myImg" src="/cssref/pineapple.jpg" alt="Pineapple" width="300" height="300"> <p><strong>Note:</strong> The filter property does not work in Internet Explorer or Edge 12.</p> <script> function myFunction() { document.getElementById("myImg").style.filter = "grayscale(100%)"; } </script> </body> </html>