I have a div, when you click it I want it to rotate and then when you click it again it rotates back, a toggle. I'm doing this with CSS transforms, and I need to add the classes also with jquery. I have the classes stored in vars and then am trying to apply them. Here is the jfiddle I'm working on, thanks for your help in advance.
here is the code:
<div id="beffects_of_yoga_info" style="width:50px;height:50px;background:red;"></div>
jquery:
$(document).ready(function() {
var css_info_timing = {
"-webkit-transform": "all 1s ease;"
}
var css_info_rotate = {
"-webkit-transition": "rotate(150deg)"
}
$("#effects_of_yoga_info").css(css_info_timing);
$("#effects_of_yoga_info").click(function () {
$("#effects_of_yoga_info").toggleClass(css_info_rotate);
});
});
css_info_timingshould use-webkit-transition, andcss_info_rotateshould use-webkit-transform. Also,css_info_rotateis not a class, so you shouldn't usetoggleClass()with that variable.