HTML select element type is 'select-one' when jQuery is included. Is it a cross browser value?
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开发者_JAVA百科 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:
console.log(document.createElement('select').type);
For select
elements, the two possible values it could take is select-one
for normal select elements, ad select-multiple
when more than one value is accepted (ie. when a valid multiple
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
精彩评论