0

Is it possible to find a text field by the text entered inside.

My exact situation is that,

I have about 4-5 text fields, and i need to find those text fields which doesn't have any text entered, i.e whose value = "" .

Any help would be of great use.

4

3 回答 3

6

你可以使用filter方法。

var $input = $('input[type=text]').filter(function(){
   return this.value === ''
})
于 2013-01-08T14:34:43.893 回答
1

您可以使用@undefined 给出的方法。以下选择对我有用,您可以尝试:

    $(":text[value=]").get()
于 2013-01-08T14:45:01.720 回答
1
$('input:text').filter(function() { return $(this).val() == ""; });

或者

$('input:text').filter(function() { return this.value == ""; });

或者

$('input:text[value=""]');
于 2013-01-08T14:57:38.147 回答