gpt4 book ai didi

javascript - 每次点击一个一个地显示 3 个 div

转载 作者:行者123 更新时间:2023-11-28 16:01:17 25 4
gpt4 key购买 nike

每次单击+ 添加更多 链接时,我需要一个帮助来一个一个地显示 3 个 div,同时 + 添加更多 链接在显示第 3 个后消失分区请帮助我

<input size="20" id="high_light1" type="text" /> 
<span><a href="#" id="add"> + Add more</a></span>
<div style="display:none;"><input size="20" id="high_light2" type="text" /></div>
<div style="display:none;"><input size="20" id="high_light3" type="text" /></div>
<div style="display:none;"><input size="20" id="high_light4" type="text" /></div>

注意:我不想生成新的 div,我需要在每次点击时生成现有 div 的 display:block

谢谢

最佳答案

如果您将使用 jQuery:

$('#add').click(function () {
$('.toAdd').each(function () {
if ($(this).css('display') == 'none') {
$(this).css('display', 'block');
return false;
}
});
var i = 0;
$('.toAdd').each(function () {
if ($(this).css('display') != 'none') {
i++;
}
});

if (i == 3) $('#add').hide();
});

在这里查看:http://jsfiddle.net/SFRgz/

关于javascript - 每次点击一个一个地显示 3 个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14931684/

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