假设我有 10 个按钮。我想隐藏除第一个按钮之外的所有按钮。
我试图使用 jQuery 中的 every() 来完成它,但它不起作用。
这是我的脚本。这只是一个测试,看看我是否可以获得按钮的索引。没有出现错误。
$('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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)