Hans Hans - 10 months ago 45
jQuery Question

Why doesn't Jquery fadeOut() work? Hide() does

After an Ajax result I'm trying to fadeOut a html button. This works most of the time, however sometimes the button isn't faded out and I can't figure out why.

type: frm.attr('method'),
url: frm.attr('action')+'?time='+timestamp,
data: frm.serialize(),
dataType: 'json',
success: function (data) {
if(data['success'] === true){

function hideSaveButton(){

Accessing the hideSaveButton() function doesn't seem to be a problem. It's just the fadeOut() function that isn't working. I tried replacing fadeOut() by hide() which works without any problem.

Any ideas?

Answer Source

It seems that the calls are being made in quick succession. Which means that the fadeOut fires before the earlier one has finished.

You may want to stop() before you attempt the fadeOut():


More info: http://api.jquery.com/stop/