我想在单击按钮时将图像旋转 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/