gpt4 book ai didi

jquery - 如何使用 jQuery 发出警报

转载 作者:行者123 更新时间:2023-12-03 21:27:38 24 4
gpt4 key购买 nike

这有效:

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

但这不是:

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

正确的 jQuery 语法是什么:

FOR EACH CLASS="overdue"
alert('Your book is overdue');
NEXT

最佳答案

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

请注意,“.addClass()”之所以有效,是因为 addClass 是在 jQuery 对象上定义的函数。您不能只是将任何旧函数放在选择器的末尾并期望它能够工作。

此外,用 n 个弹出窗口轰炸用户可能是个坏主意(其中 n = 逾期图书的数量)。

也许使用尺寸函数:

alert( "You have " + $(".overdue").size() + " books overdue." );

关于jquery - 如何使用 jQuery 发出警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2804157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com