2016-07-03 56 views
0

我不知道如何獲得第一個divform-wrapper隱藏和取消隱藏它。我想做到的是建立一個按鈕(添加語言),並單擊此按鈕時,顯示出與類的第一個隱藏的div form-wrapper獲取第一個隱藏窗體並顯示它

enter image description here

我做了什麼:(功能unhideOneForm被稱爲只有一次,現在,它是用於測試目的,但它並沒有顯示出任何形式/格。

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() 
}); 

你能檢查哪裏出了問題?

+1

'$( 「形式的包裝器:隱藏的:第一」)' –

回答

2

display : none是您<div class="form-wrapper">而不是它的孩子。

所以選擇應該是,

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

高興它幫助! –

相關問題