SoFunction
Updated on 2025-02-28

The performance differences of option elements in each browser of javascript

1. There are no events in IE6/7/8/9 (such as click, mouseover), and there are Firefox/Safari/Chrome/Opera.
Copy the codeThe code is as follows:

<select multiple="multiple">
<option value="1" onclick="alert(1);">1</option>
<option value="2" onclick="alert(2);">2</option>
</select>

Example:



2. Click option to obtain the event source target through srcElement. In IE, it is select, and Firefox/Safari/Chrome/Opera is option.
Copy the codeThe code is as follows:

<select multiple="multiple">
<option value="1" >1</option>
</select>
<script>
('s2').onclick = function(e){
var evt = || e;
var target = || ;
alert();
}
</script>

Example:



3. Adding title attribute to option element under IE6 to achieve the tips function is invalid.
Copy the codeThe code is as follows:

<select multiple="multiple">
<option value="1" title="tips">1</option>
</select>

Example: