Kris Hunt
Kris Hunt

Reputation: 2242

How to target select box in jQuery validate errorPlacement?

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.

Upvotes: 0

Views: 1647

Answers (1)

Sparky
Sparky

Reputation: 98738

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/

Upvotes: 1

Related Questions