2

I have a form where user click button to update profile. After <div> give them notice it will fade out. It works but the problem is when user click submit button again the <div> will not show again. My code in :

function(data){

    if (data.response==1) 
    { 
        $('#stage').html("<div style=\"background-color:#75A838; padding-left:20px;\">Your profile has been updated!</div>"); 
    }
    else if (data.response==0) {
    $('#stage').html("<div style=\"background-color:#FF7800; padding-left:20px;\">No changes have been made to your profile!</div>");
   }
            $('#stage').delay(2000).fadeOut();

html code

 <div id="stage" style="color: white;"></div>

What did I miss? Help me with this please. Thank you.

sg552
  • 1,521
  • 6
  • 32
  • 59

2 Answers2

5

Once fadeOut() completes it will set the div to display:none; Here's updated code:

function(data){

    if (data.response==1) { 
        $('#stage').show().html("<div style=\"background-color:#75A838; padding-left:20px;\">Your profile has been updated!</div>"); 
    } else if (data.response==0) {
        $('#stage').show().html("<div style=\"background-color:#FF7800; padding-left:20px;\">No changes have been made to your profile!</div>");
    }

    $('#stage').delay(2000).fadeOut();

}

The .show() on your div will make sure the display:none; is removed from the div.

Ishank
  • 2,860
  • 32
  • 43
Joe Spurling
  • 967
  • 11
  • 22
0

here's a few links that might be of interest :

jquery fadein fadeout

another of interest

some more of interest

Community
  • 1
  • 1
ajt
  • 553
  • 8
  • 25