Jquery 使用1个按钮逐步取消隐藏输入框和文本

Jquery 使用1个按钮逐步取消隐藏输入框和文本,jquery,Jquery,我有两个动态生成的输入框,它们附着在一些列表的底部。这些用于自定义用户输入,与选定对象一起使用。我需要在每次按下按钮时将其扩展1。我对jquery非常陌生,所以我肯定我在某些地方混淆了语法,但我不确定在哪里。当我点击按钮时,什么也没发生。我错过了什么 以下是我的jquery: var addanother; function increment(){ addanother++; $('input['.addmore'="'+ addanother +'"]').show();

我有两个动态生成的输入框,它们附着在一些列表的底部。这些用于自定义用户输入,与选定对象一起使用。我需要在每次按下按钮时将其扩展1。我对jquery非常陌生,所以我肯定我在某些地方混淆了语法,但我不确定在哪里。当我点击按钮时,什么也没发生。我错过了什么

以下是我的jquery:

var addanother;
function increment(){
    addanother++;
    $('input['.addmore'="'+ addanother +'"]').show();   
}
这是我的HTML:

<input type="button" onClick="increment()" value="Add more!"/>
<div>
<div class="addmore1" style="display: none" />
<input id="<?php echo $catkey; ?>_addone_friendly_1" type="text" class="auto" size="9" /><span> - Friendly</span><br />
<input id="<?php echo $catkey; ?>_addone_1" name="[<?php echo $catkey; ?>][]" type="text" class="auto" size="9" /><span> - Exact</span><br />
</div>
<div class="addmore2" style="display: none" />
<input id="<?php echo $catkey; ?>_addone_friendly_2" type="text" class="auto" size="9" /><span> - Friendly</span><br /><br />
<input id="<?php echo $catkey; ?>_addone_2" name="[<?php echo $catkey; ?>][]" type="text" class="auto" size="9" /><span> - Exact</span><br /><br />
</div>
... and so on
</div>


要增加某些内容,它必须以非
未定义的内容开始,并且您混合了引号:

var addanother = 0;

function increment(){
    addanother++;
    $('.addmore'+addanother).show();   
}

要增加某些内容,它必须从未定义的
以外的内容开始,并且您混合了引号:

var addanother = 0;

function increment(){
    addanother++;
    $('.addmore'+addanother).show();   
}

另一种方法是去掉序列号,只需将它们全部设置为
class=“addmore”
,然后让jquery找到第一个隐藏的序列号并显示出来

function increment() {
  $('.addmore').filter(':hidden').eq(0).show()
}

另一种方法是去掉序列号,只需将它们全部设置为
class=“addmore”
,然后让jquery找到第一个隐藏的序列号并显示出来

function increment() {
  $('.addmore').filter(':hidden').eq(0).show()
}

谢谢,但亚迪尼奥做到了。谢谢,但亚迪尼奥做到了。