rusly
rusly

Reputation: 1522

Cannot run click function when jquery delay() is active

i create simple form using jquery(ajax) and when user submit form the success message will appear slideDown() and delay for 6 second after that will slideUp() but when delay() is active i cannot close this box .

$("#show").click(function () {
    //ajax will submit form
    //$.ajax({
    //type: form34.attr("method"),
    //url: form34.attr("action"),
    //data: form34.serialize(),
    //success: function (data) {   ...
    //when success run this
    $(".message_div").addClass("message_success").slideDown().delay(6000).slideUp();
});

$(".close").click(function () {
    $(".message_div").slideUp();
}); 

Here my jsfiddle

Upvotes: 1

Views: 120

Answers (2)

Vond Ritz
Vond Ritz

Reputation: 2012

this code works for me.

 $(".close").click(function () {
        $(".message_div").stop().slideUp();
 });

Upvotes: 5

bipen
bipen

Reputation: 36541

you can stop all the currently-running animation using stop() for that element

try this

 $(".close").click(function () {
   $(".message_div").stop(true,true).slideUp();
 });

fiddle here

Upvotes: 2

Related Questions