jQuery图片顺时针(逆时针)旋转

2024-10-12 00:36:59

1、准备好需要用到的图标。

jQuery图片顺时针(逆时针)旋转

3、书写hmtl代艨位雅剖码。<div class="aaaa"><p> <a id="rotLeft" class="left" href="javascript:void(0);">&lt;&lt;向左转</a> <a id="rotRight" class="right" href="javascript:void(0);">向右转&gt;&gt;</a> </p><div id="imgBox" class="image_box"><img id="rotImg" src="images/aaaa.jpg" /></div></div>

jQuery图片顺时针(逆时针)旋转

5、书写并添加js代码。<script src="js/jquery-1.2.6.pack.js"></script><s艘早祓胂cript src="js/jquery.rotate.js"></script><script>$(function(){ var rot = 0; $("#rotRight").click(function(){ if(rot === 360){ rot = 0; } rot += 90; $("#rotImg").rotate(90); }); $("#rotLeft").click(function(){ if(rot === -360){ rot = 0; } rot -= 90; $("#rotImg").rotate(-90); }); });</script>

jQuery图片顺时针(逆时针)旋转

7、查看效果。

jQuery图片顺时针(逆时针)旋转
猜你喜欢