javascript - 通过单击按钮旋转图像

标签 javascript jquery

我想在单击按钮时将图像旋转 90 度、180 度和 360 度。

 <img class="test" id="image" src="images/image" alt="This is the Display Image" />

我用过这个脚本,但我不喜欢它,因为它只显示一个旋转...

$(document).ready(function() {
   $('#image').rotate({maxAngle:25,minAngle:-55,
      bind: [
        {"mouseover":function(){$(this).rotateAnimation(85); } },
        {"mouseout":function(){$(this).rotateAnimation(-35); } }
      ]
   });
});

最佳答案

$('input').click(function(){
    var img = $('img');
    if(img.hasClass('north')){
        img.attr('class','west');
    } else if(img.hasClass('west')){
        img.attr('class','south');
    } else if(img.hasClass('south')){
        img.attr('class','east');
    } else if(img.hasClass('east')){
        img.attr('class','north');
    }
});

fiddle :http://jsfiddle.net/JkHqa/

** 想加入动画就看JQuery animate函数

关于javascript - 通过单击按钮旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17646729/

相关文章:

javascript - 如何使用 jQuery 附加 li 并在 onclick 方法上使用 id

jQuery Tablesorter 过滤器 : Use only one filter search box for entire table?

javascript - 在新窗口中运行 Javascript.open

javascript - fancybox 和响应式文件管理器中的图像预览不起作用(空字符串传递给 getElementById()。)

javascript - 在最小化浏览器窗口的同时重新调整 Kendo 图表的大小?

javascript - selectedOptions.length 在 Internet Explorer 中不起作用,但在 Chrome 和 Firefox 中正常工作?

javascript - 重置表单(DIV 中包含的一个输入除外)

javascript - 正则表达式查找并用 gulp/node 替换并在替换中使用查找字符串的一部分?

javascript - 如何立即调用 javascript 函数而不是滚动

javascript - on Change 事件仅触发一次