oceanic815
oceanic815

Reputation: 481

JQuery: Combining animate CSS and fadeIn

This is my script:

$("#headerimage").animate({marginLeft:"0"},300);

I want to add "fadeIn" as well to start simultaneously and at the exact same speed. How is this done?

Upvotes: 1

Views: 968

Answers (2)

Ankit Tyagi
Ankit Tyagi

Reputation: 2375

$("#headerimage").animate({
    marginLeft:"0",
    opacity: 1
},300);

Upvotes: 0

adeneo
adeneo

Reputation: 318182

By animating the opacity:

$("#headerimage").animate({
    marginLeft: 0,
    opacity   : 1
}, 300);

If it's hidden with display:none, show it first:

$("#headerimage").css({
    opacity : 0,
    display : 'block' // or whatever
}).animate({
    marginLeft: 0,
    opacity   : 1
}, 300);

Upvotes: 3

Related Questions