如何使用Rotate Plugin使用按钮(如左右)旋转图像

时间:2012-03-27 19:27:06

标签: jquery jquery-ui jquery-plugins

<script type="text/javascript" src="http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js"></script>
<img src="https://www.google.com/images/srpr/logo3w.png" id="image">
<button id ="left">left</button>
<button id ="right">Right</button>



        $("#left").click({
            $("#image").rotate({ animateTo:180 })

       });

        $("#right").click({
            $("#image").rotate({animateTo:0})
       });​

Iam无法使用按钮

旋转图像

2 个答案:

答案 0 :(得分:1)

你必须将一个函数绑定到事件(在这种情况下在'click'中)

$("#left").click(function() {
            $("#image").rotate({ animateTo: 180 });

});

$("#right").click(function() {
            $("#image").rotate({ animateTo: 0 })
});​

答案 1 :(得分:1)

您错过了点击事件的function()部分:http://jsfiddle.net/2G63C/3/

他们需要:

$('#left').click(function(){