本文實例講述了jQuery實現(xiàn)的鼠標滾輪控制圖片縮放功能。分享給大家供大家參考,具體如下:
<!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" /> <title>www.gxlcms.com 鼠標滾輪控制圖片縮放</title> <script type="text/javascript" src="jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function() { function zoomImg(o) { var zoom = parseInt(o.style.zoom, 10) || 100; zoom += event.wheelDelta / 2; //可適合修改 if (zoom > 0) o.style.zoom = zoom + '%'; } $(document).ready(function() { $("img").bind("mousewheel", function() { zoomImg(this); return false; }); }); }) </script> </head> <body> <center> <img src="1.jpg"/> </center> </body> </html>
運行效果:
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery圖片操作技巧大全》、《jQuery切換特效與技巧總結(jié)》、《jQuery擴展技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com