Hi, how can one select an input "or" a select element with jQuery? I have a form, and I want to get the first element of that form that is an input or a select. So, this $('#myForm').find('input:first') or $('#myForm').find('select:first'). Any idea? Thanks
+3
A:
Have you tried something like this?
$('#myForm select, #myForm input').first()
Rob Davis
2010-06-02 22:51:57
Thanks a lot! That solved my problem.
Ricardo
2010-06-02 23:07:38
+1
A:
This should do the trick...
$('#myForm :input').first()
:input "Matches all input, textarea, select and button elements." from the jquery docs.
.first() "Reduce the set of matched elements to the first in the set." also from the jquery docs.
Dr. Frankenstein
2010-06-02 23:09:51