jquery snytax error?
I'm writing a simple function to adjust opacity, and margins on hover. Using add class. Can someone tell me what I'm doing wrong here please. Thanks alot!
http://jsfiddle.net/aDJma/3/
$(document).ready(function() {
$('.connectsocialitem').each(function() {
$(this).hover(function() {
$(this).addClass("active")
$('.active > a').animate({ opacity: 0.6 }, 300);
$('.active > a').animate({marginTop:'-5px'}, 150);
}, function() {
$(this).removeClass("active")
$('.active > a').anima开发者_运维百科te({ opacity: 1.0 }, 150);
$('.active > a').animate({marginTop:'0px'}, 150);
});
});
});
Your CSS has a text-indent of -2000 on the anchors you're animating so you'll never see the animation (the anchor is very far left of what you see). You need to animate the div that you're hovering over, or leave the anchor at a normal position and style it so it animates properly.
I've updated your jsFiddle with an example of just animating the div itself (it's a bit slow because I didn't do any optimizing, so you'll probably want to change up the animation chaining a bit).
It seems to work for me: http://jsfiddle.net/maniator/aDJma/20/
精彩评论