在集合中查找空输入元素 - jQuery [英] Find empty input elements inside a collection - jQuery
问题描述
我试图找到像jQuery结果集中的textbox,select和li元素这样的空输入类型。
我的结果集是(requiredfields) -
pre $ $ requiredFields = $(。f-form-required.f-如果($(':input:not([type =hidden])))
return $(this);
});
在结果集上,我想查询像textbox,select和li元素这样的空输入。但似乎我做错了什么。有人可以告诉我该怎么做。
目前我正在这样做,以获得空的文本框,但无法正常工作 -
var emptyInputs = 0;
$ requiredFields.filter(function(){
$('input [type = text]')。each(function(){
if(this.val ==){
emptyInputs = emptyInputs + 1;
}
});
});
我正在尝试查找空白下拉/ select元素和list / li元素requiredFields集合。
没有 val
属性。尝试使用 .val()
或 this.value
:
var emptyInputs = 0;
$ requiredFields.filter(function(){
$('input [type = text]')。each(function(){
if(jQuery(this).val()= =){
emptyInputs = emptyInputs + 1;
}
});
});
或:
var emptyInputs = 0;
$ requiredFields.filter(function(){
$('input [type = text]')。each(function(){
if(this.value ==){
emptyInputs = emptyInputs + 1;
}
});
});
I am trying to find the empty input types like textbox, select and li elements inside a jQuery resultset. My resultset is (requiredfields) -
$requiredFields = $(".f-form-required.f-form-field").filter(function(){
if($(':input:not([type="hidden"])'))
return $(this);
});
And on that resultset I want to query for empty inputs like textbox, select and li elements. But it seems I am doing something wrong. Can someone suggest me how to do that.
Currently I am doing this to get empty textboxes but not working -
var emptyInputs = 0;
$requiredFields.filter(function(){
$('input[type=text]').each(function(){
if (this.val == "") {
emptyInputs = emptyInputs + 1;
}
});
});
I am trying to do same for finding out empty dropdown/select elements and list / li elements over $requiredFields collection.
There is no val
property. Try using .val()
instead or this.value
:
var emptyInputs = 0;
$requiredFields.filter(function(){
$('input[type=text]').each(function(){
if (jQuery(this).val() == "") {
emptyInputs = emptyInputs + 1;
}
});
});
or:
var emptyInputs = 0;
$requiredFields.filter(function(){
$('input[type=text]').each(function(){
if (this.value == "") {
emptyInputs = emptyInputs + 1;
}
});
});
这篇关于在集合中查找空输入元素 - jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!