本文實例講述了jQuery實現響應鼠標事件的圖片透明效果。分享給大家供大家參考,具體如下:
實現的思想:
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="Content-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><title>圖片透明</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選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
新聞熱點
疑難解答