试图在jquery中旋转按钮?

时间:2013-07-08 11:12:57

标签: jquery html css

我正在尝试在jquery中旋转一个按钮!

这是我在jsfiddle上创建的

http://jsfiddle.net/QVKjt/1/

jquery代码

$("#no").rotate({ 
    angle:0,
        bind: {
            click : function(){
                var curAngle = parseInt($(this).getRotateAngle());
                $(this).rotate({
                    angle: curAngle,
                    animateTo: curAngle + 30
                });
            }
        }
   });

3 个答案:

答案 0 :(得分:2)

.rotate()不是官方的jQuery函数,您需要手动加载它。

要执行此操作,download the library by clicking here并使用此功能参考您的应用程序:

<script type="text/javascript" src="js/jQueryRotate.2.2.js"></script>

在jsFiddle中我只添加一个外部库。要查看工作,click here

答案 1 :(得分:2)

试试这个

var rotation = 0;

jQuery.fn.rotate = function(degrees) {
    $(this).css({'-webkit-transform' : 'rotate('+ degrees +'deg)',
                 '-moz-transform' : 'rotate('+ degrees +'deg)',
                 '-ms-transform' : 'rotate('+ degrees +'deg)',
                 'transform' : 'rotate('+ degrees +'deg)'});
};

$('#no').click(function() {
    rotation += 30;
    $(this).rotate(rotation);
});

查看fiddle演示

答案 2 :(得分:1)

也许这对你很有帮助。

$("#no").rotate({ 
angle:0,
    bind: {
        click : function(){
            $(this).rotate({
                angle: 0,
                animateTo:  30
            });
        }
    }
});

查看演示:http://jsfiddle.net/QVKjt/8/

相关问题