2016-03-05 85 views

回答

0

您可以使用jQuery的。每个函数指向同类型“文本”的所有输入单元选择。事情是这样的:

var nonNullInputs=new Array(); 
$(':text').each(function(index,value){ 
if($(this).val()!=null){ 
//get the id of the non null text input and push it for example in an array 
//the index parameter returns the number of the input element by order in the form, 
//the value parameter return the value 
nonNullInputs.push($(this).attr('id')); 
}}); 
//now you have an array named nonNullInputs with all the inputs with type text which are not empty. 

我希望这有助于:-)

+0

谢谢DevMan。这很奏效。 –