tags:

views:

44

answers:

4

Hello all,

I have a page as follows:

<div id="warning_msg">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo.
<span id="closeerrordiv" class="notify-close">×</span>
</div>
<div id="bigForm2">
    Lots of content here    
</div>
<div id="bigForm...">
</div>
<div id="footer">
</div>

<script type="text/javascript">    
$(document).ready(function() {
    $('#closeerrordiv').click(function() {
        $(this).parent().fadeOut('slow');
    });
});    
</script>

After the user clicks 'closeerrordiv', the span content will fadeout. Now, I need to move all the bottom parts move up.

Howe can I do this?

+1  A: 

Specify the callback function to fadeOut like this to slide up the element after fading completes:

$(this).parent().fadeOut('slow', function(){
  $('#element_id').slideUp('slow');
});

Where element_id is the id of the element you want to move/slide up.

Sarfraz
Hello Sarfraz,I don't have one solid element_id that contains all the bottom parts.
q0987
Author means 'a jump' after fading. This will not solve his problem.
Sergey
@q0987: So which element you want to slide up then, which parts of html in your question, you have not mentioned this. We can not understand what you mean by bottom parts.
Sarfraz
He ment that after fading of the 'top' the 'bottom' should slide but not jump => so the 'top' should slide actually just after fading
Sergey
A: 

Add slideUp() right after the fadeOut().

$(this).parent().fadeOut('slow');
$(this).parent().slideUp('slow');
DLH
this will do them both at the same time.
Catfish
Will it? I was going on the code samples at http://api.jquery.com/queue/. Maybe I just interpreted it wrong?
DLH
A: 

im not sure what you mean by what you said.

it sounds like you want the 'x' to fade out and then slide out the warning message. to do that do the following javascript.

$(document).ready(function() {
    $('#closeerrordiv').click(function() {
        $(this).fadeOut('slow',function(){
            $(this).parent().slideUp();
        });
    });
});
jairajs89
Hello jairajs89,When the click happens, the parent of span #closeerrordiv (i.e., warning_msg) disappear.Here is what I want to do:I would like to use animation so that the DIV #bigForm2, ..., #footer are sliding up.what happens now is that all the DIV are jumping to above.Thank you
q0987
+1  A: 

The 'jump' happens because fadeOut() function in the end sets 'display' to 'none'.
This will solve your problem:

$(this).parent().animate({opacity: 0}, 'slow', function() {
  // fade complete.
  $('#warning_msg').slideUp('slow');
});

If you want simultaneous fading and sliding just write:

$(this).parent().fadeOut('slow');
$(this).parent().slideUp('slow');
Sergey
Excellent!!!This is exactly what I am looking for!
q0987