tags:

views:

18

answers:

1

I am using jquery to find a first element having a class "error" applied to it using the below code

$('#mainDiv input.error:eq(0)')

But the above one working only for input elements only. How to make this one to work for both input and select elements?

+2  A: 
$('#mainDiv .error:eq(0)')

or

$('input.error, select.error', '#mainDiv').first()

if you want to find only input and select objects

silent
Actually this class is applied for lot of elementsI want to find first input or select elements having class error
Sandeep
so use my second example
silent
Thanks for this its working :)
Sandeep
you're welcomeuse this for the first time you use jquery - http://visualjquery.com/
silent