How to “fadeOut” & “remove” a div in jQuery?

后端 未结 7 1456
醉酒成梦
醉酒成梦 2020-12-12 09:43

I\'m trying to give fadeout effect to a div & delete that div(id = \"notification\"), when an image is clicked.

This is how I\'m doing that:

<         


        
7条回答
  •  暖寄归人
    2020-12-12 09:55

    Have you tried this?

    $("#notification").fadeOut(300, function(){ 
        $(this).remove();
    });
    

    That is, using the current this context to target the element in the inner function and not the id. I use this pattern all the time - it should work.

提交回复
热议问题