How to alert using jQuery

后端 未结 3 756
野性不改
野性不改 2021-01-30 16:10

This works:

$(\'.overdue\').addClass(\'alert\');

But this doesn\'t:

$(\'.overdue\').alert(\'Your book is overdue.\'); 
<         


        
3条回答
  •  梦谈多话
    2021-01-30 16:47

    Don't do this, but this is how you would do it:

    $(".overdue").each(function() { 
        alert("Your book is overdue"); 
    });
    

    The reason I say "don't do it" is because nothing is more annoying to users, in my opinion, than repeated pop-ups that cannot be stopped. Instead, just use the length property and let them know that "You have X books overdue".

提交回复
热议问题