Hi创建了一个div结构,该结构将允许用户插入多个与每个办公室相关的办公室号码和地址。即办公室一,办公室二等

我在这些部分之间滑动。我有8个电话号码,我使用jQuery隐藏未打勾的电话号码,然后单击“添加新号码”,它将显示列表中的下一个号码。

但是,因为这仅适用于名为办公室一的部分,而不适用于办公室二的部分。如果您能够单击添加新号码并在第一个办公室然后在第二个办公室进行测试,您将看到不同之处。单击添加按钮时,它还应该附加一个隐藏和清除链接,但是未附加该链接。

我的添加功能如下所示或查看我的jsFiddle

$(".add").click(function () {
 $(this).closest('.togglesettings').find(".contact_numbers:hidden:first").fadeIn("slow", function () {
             $(this).find('.remove').remove();
                 $(this).find('.clearnumber').remove();
                 $(this).find('.contact_numbers .input_tel:last-child').append("<a href='#' class='remove'>Hide</a><a href='#' class='clearnumber'> Clear #</a>")
            });
    });


但是,当我使用表结构时,该方法起作用,单击该jsFiddle

最佳答案

在您的添加点击处理程序中,更改:

$(this).closest('.togglesettings').find(...




$(this).closest('.form-group.container').find(...


jsFiddle example

关于javascript - jQuery查找下一个不适用于div结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21783558/

10-11 02:41
查看更多