jQuery旋转div onclick +/- 90 [英] jQuery rotate div onclick +/-90

查看:196
本文介绍了jQuery旋转div onclick +/- 90的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种简单的方法可以在单击后将div旋转+90度,并在下次单击时将其返回0度(以便div旋转-90度). 由于找不到任何东西,所以我一直在寻求您的帮助.谢谢.

I was wondering if there is an easy way to rotate a div +90 degrees after clicking it and by clicking it next time it returns to 0 degrees (so that the div rotates -90 degrees). Since I couldn't find anything I was looking for your help. Thanks.

推荐答案

您可以使用toggleClass并将css转换应用于该类:

You could use toggleClass and apply css transform to that class:

$('#rotate').click(function(){
    $(this).toggleClass('rotated');
});

小提琴

.rotated { 
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    -o-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
}

这篇关于jQuery旋转div onclick +/- 90的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆