gpt4 book ai didi

jquery - 如何知道jQuery上的具体列表?

转载 作者:行者123 更新时间:2023-12-01 06:39:09 24 4
gpt4 key购买 nike

我在 jQuery 中有这个悬停事件。有多个<li>在这里标记

$("ul#mainnav li").hover(function(){
if($(this) == $("ul#mainnav li:eq(1)")){
alert("yes");
} else {
alert("no");
}
})

这行不通。感谢您的帮助。

最佳答案

如果你想知道触发事件的元素的索引,你可以这样做

index = $("#mainnav li").index(this);
if (index == 1)...

关于jquery - 如何知道jQuery上的具体列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7642520/

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