How do you test an input field for type "select", e.g. for a radio button, it's
if($('#' + field).attr('type') == 'radio'{
....
}
What do you write for a select box?
How do you test an input field for type "select", e.g. for a radio button, it's
if($('#' + field).attr('type') == 'radio'{
....
}
What do you write for a select box?
You can use .is()
and an element selector, like this:
if($('#' + field).is('select')) {
Or check .length
of an #id
selector only for that element type like this (a bit slower):
if($('select#' + field).length) {
Or nodeName
(or tagName
) like this:
if($('#' + field)[0].tagName == 'SELECT') {
Or without jQuery at all (fastest):
if(document.getElementById(field).tagName == 'SELECT') {