JS 编程,onmouseover 图片变模糊问题
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript"> var img =document.getElementById("img"); function setover(abc){ abc.style['opacity'] = 0.5; abc.style['filter'] = 'alpha(opacity=50)'; }; function setout(abc){ abc.style['opacity'] = 1; abc.style['filter'] = 'alpha(opacity=100)'; }; img.addEventListener("mouseover",function setover(abc),false); img.addEventListener("mouseout",function setout(abc),false); </script> </head> <body> <ul id="imagegallery"> <li><img id="img" src="人物a.jpg"></li> </ul> </body> </html>
function moveover(){ var img =document.getElementById("img"); function setover(abc){ abc.style['opacity'] = 0.5; abc.style['filter'] = 'alpha(opacity=50)'; }; function setout(abc){ abc.style['opacity'] = 1; abc.style['filter'] = 'alpha(opacity=100)'; }; img.addEventListener("mouseover",function setover(abc),false); img.addEventListener("mouseout",function setout(abc),false);
在Chrome 浏览器上 显示的报错是Uncaught SyntaxError: Unexpected token ,。
我想做到html 与JS 完全分离,但是遇到瓶颈,求大神帮帮忙!另外小弟今年4月22日自学代码 html→CSS→JS ,大神们有什么好书推荐
如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

评论(5)


<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <img id="img" src="http://www.oschina.net/img/logo_s2.png"> </body> </html> <script type="text/javascript"> var img =document.getElementById("img"); function setover(){ this.style['opacity'] = 0.5; this.style['filter'] = 'alpha(opacity=50)'; }; function setout(){ this.style['opacity'] = 1; this.style['filter'] = 'alpha(opacity=100)'; }; img.addEventListener("mouseover", setover); img.addEventListener("mouseout", setout); </script>
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。