Sunil Chaudhry Sunil Chaudhry - 22 days ago 6
jQuery Question

how to find first input/select in jquery

I used the following line to do so, but it fails when a select comes on the form. It lefts select and then it stops working even for inputs.

var $ele = $("select,input[type='text'],input[type='password']:visible[required]").filter(function ()
{ return this.value.trim() == '' || this.value.trim().indexOf('--') != -1 ;
}).eq(0);

Answer

You may looking for below code.

$('form').find('input[type=text],select').filter(':visible:first')
Comments