1.頁面引入jquery.rotate.js文件, 下載地址:https://files.cnblogs.com/files/zhoujl-5071/jquery.rotate.js(打開這個網址,ctrl+s就好了)
<script type="text/javascript" src="js/jquery.rotate.js"></script>
文件路徑根據自己實際情況來寫。
2.或頁面加載直接執行,或通過綁定事件觸發,讓目標元素轉起來
$('#container').rotate({ bind : { mouseover : function(){ $(this).find(".icon").rotate({animateTo: 180,duration:500}); }, mouseout : function(){ $(this).find(".icon").rotate({animateTo: 0,duration:500}); } } });
我這里實現的效果是:鼠標移到'#container'上邊時,'icon'順時針旋轉180度(用時0.5秒),鼠標移出時逆時針旋轉180度(用時0.5秒)。
更多的用法請參考: https://www.cnblogs.com/cc11001100/p/6354234.html