javascript当中option事件冒泡
4.option事件冒泡
马克-to-win:onChange事件option谈不到,只有select才谈onChange。只有onClick事件二者都有,才谈到冒泡。
例 4.1(getElementsByTagName()IEFF.html)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.οnlοad=function(){
var arr = document.getElementsByTagName("option");
alert("arr[i].value is "+arr[2].value);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<SELECT NAME="" onChange="document.getElementById('info').innerHTML+='select';" id="province" style="width:140px;
<option onChange="document.getElementById('info').innerHTML+='option hong';">红</option>
<option onChange="document.getElementById('info').innerHTML+='option lan';">兰</option>
<option value="紫">紫1</option>
</SELECT>
<span id="info"></span>
</BODY>
</HTML>
例 4.2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</HEAD>
<BODY>
<SELECT NAME="" onClick="document.getElementById('info').innerHTML+='select';" id="province" style="width:140px;background-color:red">
更多内容请见原文,文章转载自:https://blog.csdn.net/qq_43650923/article/details/103051109