Reputation: 1450
i am using jquery to change child div's background when hovering main div.
$('#bottom-a .module.responsive').hover(function () {
$('#bottom-a .responsive .mod-icon').css({
"background-position": "left bottom"
});
}, function () {
$('#bottom-a .responsive .mod-icon').css({
"background-position": "left top"
});
});
How to add animation to this script? Thanx!
Upvotes: 0
Views: 207
Reputation: 1881
You can do it simply with css without modifying your code :
#bottom-a .responsive .mod-icon {
background-image:url('imgurl.jpg');
transition: background 2s;
-moz-transition: background 2s; /* Firefox 4 */
-webkit-transition: background 2s; /* Safari and Chrome */
-o-transition: background 2s; /* Opera */
}
Upvotes: 1
Reputation: 7349
$('#bottom-a .module.responsive').hover(function () {
$('#bottom-a .responsive .mod-icon').animate({
"background-position": "left bottom"
},1000);
}, function () {
$('#bottom-a .responsive .mod-icon').animate({
"background-position": "left top"
},1000);
});
Upvotes: 0