我绝对是 jquery 的初学者。我正在使用谷歌来学习,但我找不到如何解决这个简单的问题。
我用一个按钮连续显示 div,但我想在没有更多 div 可显示时隐藏显示按钮。
这是代码:
$('#show').on('click', function() {
if (index + 1 > max) {
// Here, I suppose, I need to hide the button
} else {
if (index < max - 1) {
index++;
$('.container > div:eq(' + index + ')').show();
}
在这里您可以看到示例
提前致谢,对我的英语感到抱歉;)
最佳答案
基本上你需要在完成运行这样的函数时执行此操作
var index = -1;
var max = $('.container > div').length;
$('#show').on('click', function() {
if (index < max - 1) {
index++;
$('.container > div:eq(' + index + ')').show();
}
}, function () {
$(this).hide();
});
这应该适合你
关于jquery - 当我完成 onclick show div 时隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14423837/