Skip to content

Instantly share code, notes, and snippets.

@erikreagan
Created May 13, 2010 17:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikreagan/400088 to your computer and use it in GitHub Desktop.
Save erikreagan/400088 to your computer and use it in GitHub Desktop.
// Why would example 1 work, but example 2 not work? (only difference is the opacity property)
// jQuery 1.4.2 in use
// Example 1
$("ul.pagination li a").hover(
function(){
$(this).siblings('.thumb').animate({
top: "-80px",
opacity: 'toggle'
},500);
},
function(){
$(this).siblings('.thumb').animate({
top: "-90px",
opacity: 'toggle'
},300);
}
);
// Example Two
$("ul.pagination li a").hover(
function(){
$(this).siblings('.thumb').animate({
top: "-80px",
opacity: 1
},500);
},
function(){
$(this).siblings('.thumb').animate({
top: "-90px",
opacity: 0
},300);
}
);
@erikreagan
Copy link
Author

I determined that the problem was how jQuery interprets the opacity property 'toggle' versus a numeric value. When set to 'toggle' it also sets the display property during the animation. If you give it a numeric value it just changes the opacity values.

So, if your element has a CSS display property set to "none" then animating to a numeric value will not change anything for you. Hence my problem above.

Problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment