How to target select box in jQuery validate errorPlacement?

1.6k views Asked by At

If I had an input of type "radio", I would target it like this:

if (element.attr("type") == "radio")

How do you target a select box? I've tried:

if (element == "select")

but that doesn't work. I know it's got to be something simple, but I just don't know the syntax.

1

There are 1 answers

0
Sparky On BEST ANSWER

Since element refers to the whole object, you can't just compare it to select with a comparison operator ==.

Simply use the .is() method for this...

if ( element.is('select') ) { ....

DEMO: http://jsfiddle.net/18xogtk3/