You missed the point of toggleClass
a little. Your rotate class should have the rotated styles. when you call .css()
, you're setting the css of the element directly, which is why only the first click seems to work - it sets those exact css styles each time. The rotate class doesn't exist, so toggling it doesn't change the appearance:
$(".arrow").on("click", function () {
$(this).toggleClass("rotate");
});
...
.rotate {
-moz-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
}