PDA

View Full Version : jQuery help


skmd
07-08-2008, 01:40 PM
Hi everybody:
I'm new to jQuery , I need after event to do an effect and after the effect completed do another effect, I tried to do it this way:

function hide(){
$('#output1').fadeIn('slow');
$('#add-comment').slideUp('slow');
}


but they appeared in the same time, can anybody help me with this.

Bill Posters
07-08-2008, 01:50 PM
Jquery's fadeIn() method takes a 'callback' method as a second, optional argument.

This would be the action it takes after completing the primary action.

e.g.
function hide() {

$('#output1').fadeIn('slow', function() { $('#add-comment').slideUp('slow')});

}

More info:
http://docs.jquery.com/Effects/fadeIn#speedcallback

skmd
07-08-2008, 01:57 PM
I tried to do it before but it didnt work. and your function has a missing $ sign

function hide() {

$('#output1').fadeIn('slow', function() {$('#add-comment').slideUp('slow')});

}


But thanks anyway :)

Bill Posters
07-08-2008, 02:11 PM
(Code example update)


It should work fine. The problem may be elsewhere in your code.

Are you getting any errors reported?
Are you able to post the url?

skmd
07-08-2008, 02:32 PM
Yes there was an error somewhere else in my code it works like a magic.
Thank you very much :)