When I alerted the type of a select element in JavaScript it displayed 'select-one'. But I thought it would display an empty string.
alert(document.getElementById('catsel').type)
// where catsel is a select box. it displayed select-one
I tested this in Firefox 3.0.0.10
Is it a cross browser value? I have never used this property until now. I just want to know whether the value select-one is the same in all browsers.
Besides I am using jQuery in my page. When I searched throughout the project for the string "select-one" matches were found in jquery.js. So I conclude that when the page had loaded jQuery is setting a property 'type' to the select elements. Am I right?
The
type
property is actually a DOM property native to form input elements, and doesn't have anything to do with jQuery - you can quickly corroborate this by running this on any website:For
select
elements, the two possible values it could take isselect-one
for normal select elements, adselect-multiple
when more than one value is accepted (ie. when a validmultiple
attribute is set).The value should be cross-browser compatible - I could not find any information disputing this.
Reference: https://developer.mozilla.org/en/DOM/select.type