简体   繁体   English

获取第一个隐藏表格并显示它

[英]Get first hidden form and show it

I can't figure out how to get first div with class form-wrapper which is hidden and unhide it. 我不知道如何使用隐藏的类form-wrapper来获取第一个div并取消隐藏它。 What I want to accomplish is to create a button (Add Language) and when this button is clicked, show the first hidden div with class form-wrapper 我要完成的工作是创建一个按钮(添加语言),然后单击此按钮,显示带有类form-wrapper的第一个隐藏的div。

在此处输入图片说明

What I've done: (the function unhideOneForm is called just once, for now, it's for testing purposes, but it does not show any form/div. 我所做的事情:(函数unhideOneForm仅被调用一次,目前,它仅用于测试目的,但不显示任何form / div。

function unhideOneForm(){
    $(".form-wrapper :hidden:first").slideToggle("fast");
}
$(document).ready(function(){
    var divs = $('.form-wrapper');
    $.each(divs, function(div){
        //alert($(this).html());
        if ($(this).find('select option:selected').text().indexOf("----") >= 0){

            $(this).hide()
        }
    });
    unhideOneForm()
});

Could you check where is the problem? 您能检查问题出在哪里吗?

The display : none is on your <div class="form-wrapper"> and not its children. display : none在您的<div class="form-wrapper">而不是其子目录上。

So the selector should be, 所以选择器应该是

$(".form-wrapper:hidden:first")
              //^ - remove the space - it is for child selector.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM