2011-07-28 11 views
1

特定の入力をスキップIは、入力フォームをクリアするため、以下の機能を持っている:jQueryのセレクタ -

function clearForm(form) { 
    $(':input', form).each(function() { 
    var type = this.type; 
    var tag = this.tagName.toLowerCase(); 

    if (type == 'text' || type == 'password' || tag == 'textarea') 
     this.value = ""; 
    else if (type == 'checkbox' || type == 'radio') 
     this.checked = false; 
    else if (tag == 'select') 
     this.selectedIndex = -1; 
    }); 
}; 

は、私は「隠された」であり、入力をクリアするからそれを停止することができます方法はありますか?

ありがとうございます。

答えて

3

確かに、代わりの

$(':input', form) 

使用

$(':input:visible', form) 
+0

パーフェクト。ありがとうございました – martok

0

$(':input:visible', form).each(...

0
$(':input:visible').val([]) 
あなたは、各機能に意思上記の単一の行をコードのいずれかを必要としない

それをやる。