gpt4 book ai didi

jQuery - 隐藏除第一个元素之外的所有元素

转载 作者:行者123 更新时间:2023-12-01 06:23:49 26 4
gpt4 key购买 nike

假设我有 10 个按钮。我想隐藏除第一个按钮之外的所有按钮。

我尝试使用 jQuery 中的each() 来完成它,但它不起作用。

这是我的脚本。这只是一个测试,看看我是否可以获得按钮的索引。没有出现任何错误。

$('button').each(function(index){
alert(index);
});

其他信息:

我的整个脚本是这样的

$(function(){
$('div#here').load('test.php'); // This is where all the buttons will come from
$('button').each(function(index){
alert(index);
});
});

最佳答案

试试这个:

Slice()提供更好的性能

$('button').slice(1).hide();

关于jQuery - 隐藏除第一个元素之外的所有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10462380/

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