MeltingDog
MeltingDog

Reputation: 15488

JQuery: slide not working as expected

This will hopefully be a simple one: I have a div I want to slide into the screen when the page loads.

I'm trying to find out why this works:

$(function() {
    $('.mydiv').slideDown(500);
});//END ONLOAD

But not this:

$(function() {
    $('.mydiv').show('slide', { direction: 'down' }, 500);
});//END ONLOAD

Can anyone give me some advice? Thanks!

(ps: CSS is .mydiv {display:none;}

Upvotes: 0

Views: 1797

Answers (2)

charlietfl
charlietfl

Reputation: 171700

jQuery core does not include effects for show() method, however jQueryUI extends show() with effects. Code you have displayed would require you to include jQueryUI library ( or components) along with jQuery .

show( effect, [options], [speed], [callback] )

jQuery UI show() docs

Upvotes: 1

Jason Kulatunga
Jason Kulatunga

Reputation: 5894

The Jquery API docs for the show method state that the show method defintions are as follows:

.show()
.show( duration [, callback] )
.show( [duration] [, easing] [, callback] )

where:

duration - A string or number determining how long the  animation will run. 
easing - A string indicating which easing function to use for the transition. 
callback - A function to call once the animation is complete.

the correct implementation using show would be

.show(500);

Upvotes: 0

Related Questions