0

I am trying to hide elements after the element has appeared for 2 seconds.

I am trying:

function hideNotif(i) {
  $('#'+i).fadeOut();
}

for (var i = 0; i <= 10; i++) {
  setTimeout(function () {
    hideNotif(i);
  }, 2000);
}

It only hides the first element however.

jSmith
  • 275
  • 1
  • 4
  • 13

1 Answers1

0
function hideNotif() {
    for (var i = 0; i <= 10; i++)
        $('#'+i).fadeOut();
}

//call like this.
setTimeout(hideNotif, 2000);
rrk
  • 15,677
  • 4
  • 29
  • 45