The issue is that you're using the $n
variable without declaring it the function, so it's getting auto-created at the global scope, which means that in your setTimeout
function the $n is referring to the global variable which will be set by the most recent time that NewNotice
is run.
To fix it, just add var
to when you're creating your variables.
var $n2 = $(this);
var $n = $('.notices').children().last();