1. There are no events in IE6/7/8/9 (such as click, mouseover), and there are Firefox/Safari/Chrome/Opera.
<select multiple="multiple">
<option value="1" onclick="alert(1);">1</option>
<option value="2" onclick="alert(2);">2</option>
</select>
2. Click option to obtain the event source target through srcElement. In IE, it is select, and Firefox/Safari/Chrome/Opera is option.
<select multiple="multiple">
<option value="1" >1</option>
</select>
<script>
('s2').onclick = function(e){
var evt = || e;
var target = || ;
alert();
}
</script>
3. Adding title attribute to option element under IE6 to achieve the tips function is invalid.
<select multiple="multiple">
<option value="1" title="tips">1</option>
</select>
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: