Unless the element is hidden, no fade will occur, you need something like this:
$(".warning").hide().fadeIn(4000);
You can give it a try here, also $()
is deprecated in 1.4+, you should use $(document)
or the shorter version, like this:
$(function() {
$(".warning").hide().fadeIn(4000);
});
The alternative is to give the element a display: none
initially but this breaks for JS-disabled users, or if JavaScript errors occur preventing the fade, so you may want to steer clear of this approach.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…