点击图片改变图片边框颜色,今天我们就来介绍通过JavaScript实现点击图片500毫秒后显示红色边框的方法
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>js实现点击图片500毫秒后显示红色边框(含源码)www.woaidaogu.com</title> <style> #box{ border: 10px solid #8a4419; cursor:pointer; } </style> </head> <body> <img src="images/hua.jpg" id="box" width="300px" height="200px" style="" /> <script type="text/javascript"> document.getElementById("box").addEventListener("click",function(){ var self=this; //缓存 this 对象 setTimeout(function(){ self.style.borderColor='red'; },500) },false); </script> </body> </html>
通过以上内容我们知道了js实现点击图片500毫秒后显示红色边框的方法,感谢您访问“我爱捣鼓(www.woaidaogu.com)”网站的内容,希望对大家有所帮助!引用本文内容时,请注明出处!谢谢合作!