javascript当中option事件冒泡

马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
马克-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.onload=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;background-color:red">
    <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">
    <option onClick="document.getElementById('info').innerHTML+='option hong';">红</option>
    <option onClick="document.getElementById('info').innerHTML+='option lan';">兰</option>
    <option>紫</option>
</SELECT>
<span id="info"></span>
</BODY>
</HTML>