2013-09-26 23 views
1

隱藏所有的表單元素我想選擇使用jQuery,我知道我可以使用選擇使用jQuery,除了那些由CSS

$(':input') 

做所有的表單元素,但後來我不想選擇元素

<input type="hidden" /> 
:由CSS,我可以做

$(':input:visible') 

,但有一兩件事,我希望得到的是這些隱藏3210

我只是不想讓被隱藏,因爲他們或他們的父母是隱藏的東西,如元素:

style="display:none;" 

的思考?

謝謝!

+1

我不認爲用單個選擇器 –

+1

可以嘗試像'$(':input:visible')。add($('input [type =「hidden」]'))' –

+0

或者你可能不得不使用'.filter()'''如'$(':input')。filter(function(){ return .parent()。is(':hidden'))|| !$(本)。是( ':隱藏'); })' –

回答

2

嘗試

$(':input').filter(function() { 
    return (this.type.toUpperCase() == 'HIDDEN' && !$(this).parent().is(':hidden')) || !$(this).is(':hidden'); 
}) 

(':input:visible').add($('input[type="hidden"]'))