JQuery: merging div functions fadeOut + .live () + .delay ()

Hello everyone I want this div to disappear when it appears. It works this way now, but since a div is sometimes added after loading (), I will need to somehow merge it with live (), I think ....

//Fade out the result alert.

$('.Alert').delay(6000).fadeOut(500);

Any ideas on how to do this?

Thanks in advance

+3
source share
1 answer

It depends on how you add your div to the page after load().

After adding an element to your page, add the handler or function that you want to have.

Example:

$('<div class="Alert"></div>').appendTo('body').delay(6000).fadeOut(500);

Living example

+1
source

Source: https://habr.com/ru/post/1776710/


All Articles