实现的思想:
1、当鼠标放在图片上面的时候触发mouseover mouseenter两个事件(图片变得透明)
2、当鼠标离开图片的时候触编程客栈发mouseleave mouseout两个事件(图片变为不透明)
具体代码如下:
<!DOCTYPE html PUBLIC "编程客栈-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Cohttp://www.cppcns.comntent-Type" content="text/html; charset=utf-8" /> <script src="jquery-1.6.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready( function(){ $("#img_id").bind("mouseover mouseenter",function(){ $(this).fadeTo("slow", 0.66); }); $("#img_id").bind("mouseleave mouseout",function(){ $(this).fadeTo("fast", 1); }); } ); </script> <ti编程客栈tle>图片透明</title> </head> <img src="logo.gif" id="img_id" height="78" width="215"/> <body> </body> </html>
完整实例代码点击此处本站下载。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常用插件及用法总结》、《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery拖拽特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》
希望本文所述对大家http://www.cppcns.comjQuery程序设计有所帮助。
本文标题: jQuery实现响应鼠标事件的图片透明效果【附demo源码下载】
本文地址: http://www.cppcns.com/wangluo/javascript/153803.html
© 著作权归作者所有
举报
发表评论
0/200