当前位置:Gxlcms > JavaScript > jQuery做出鼠标滚轮操作图片缩放大小

jQuery做出鼠标滚轮操作图片缩放大小

时间:2021-07-01 10:21:17 帮助过:4人阅读

这次给大家带来jQuery做出鼠标滚轮操作图片缩放大小,jQuery做出鼠标滚轮操作图片缩放大小的注意事项有哪些,下面就是实战案例,一起来看一下。

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>鼠标滚轮控制图片缩放</title>
  6. <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  7. <script type="text/javascript">
  8. $(function() {
  9. function zoomImg(o) {
  10. var zoom = parseInt(o.style.zoom, 10) || 100;
  11. zoom += event.wheelDelta / 2; //可适合修改
  12. if (zoom > 0) o.style.zoom = zoom + '%';
  13. }
  14. $(document).ready(function() {
  15. $("img").bind("mousewheel",
  16. function() {
  17. zoomImg(this);
  18. return false;
  19. });
  20. });
  21. })
  22. </script>
  23. </head>
  24. <body>
  25. <center>
  26. <img src="1.jpg"/>
  27. </center>
  28. </body>
  29. </html>

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:



以上就是jQuery做出鼠标滚轮操作图片缩放大小的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行