I am trying to rotate a soan class called .arrow on mouseenter event to 90 degree. This is easily possible with CSS3 transformation as:
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
I tried to use same code in jquery but it is not working! Can you please let me what is wrong with my code?
$( document ).ready(function() {
$(".list").on("mouseenter", function() {
$( '.arrow' ).css({'background-position':'0px 0px',
'-webkit-transform': 'rotate(90deg)',
'-moz-transform': 'rotate(90deg)',
'-o-transform': 'rotate(90deg)',
'-ms-transform':'rotate(90deg)',
'transform': 'rotate(90deg)'
});
});
});
UPDATE
Here is the JSFIDDLE Link
and code is like
<div class="list"></div>
<p>
<div class="arrow"></div>
$( document ).ready(function() {
$(".list").on("mouseenter", function() {
$( '.arrow' ).css({'background-position':'0px 0px',
' -webkit-transform': 'rotate(90deg)',
'-moz-transform': 'rotate(90deg)',
'-o-transform': 'rotate(90deg)',
'-ms-transform':'rotate(90deg)',
'transform': 'rotate(90deg)'
});
}).on("mouseleave", function() {
$( '.arrow' ).css({' -webkit-transform': 'rotate(-90deg)',
'-moz-transform': 'rotate(-90deg)',
'-o-transform': 'rotate(-90deg)',
'-ms-transform':'rotate(-90deg)',
'transform': 'rotate(-90deg)'
});
});
});
IMPORTANT the code rotate without using the second part of the code. I mean the .on("mouseleave" part if you delete that part first part of code rotates the box!
.arrowelement(s) do you see any updated HTML? Otherwise are you getting an error in your JS console? Also, you can useaddClass()to add a class to the element instead, and then you setup CSS for the class that has your rotation transform.