I have this code:
$('#foo').click(function () {
var xyz = $('#foo2').val().length;
if(xyz < 1) {
$('#msg').html('<div id="error">error</div>').delay(3000).fadeOut(1000);
} else ......
and i’m having issues with this line:
$('#msg').html('<div id="error">error</div>').delay(3000).fadeOut(1000);
It shows an error message if xyz is 0 but the problem is it only works once and I need it to work multiple times so if on click 2nd, 3rd, 4th time etc it pops back up, is there a way to clear/reset .html() so it can be used again?
You don’t need to clear/reset it. all you need to do is show it.
.html()uses.empty()internally before it usesinnerHTML