<body>
<div id="div_sel"></div></body>
</html>
<script type="text/javascript" >
var kk="hellozhanghua";
var cs="<select id='select1' size='40' ><option value='1' onclick='cs()'>标准标准标准</option></select>";
document.getElementById("div_sel").innerHTML=cs;
function cs(){
alert("hello");
}
</script>一段很简单的代码,我这里onclick事件不能被执行,为什么哦?
<div id="div_sel"></div></body>
</html>
<script type="text/javascript" >
var kk="hellozhanghua";
var cs="<select id='select1' size='40' ><option value='1' onclick='cs()'>标准标准标准</option></select>";
document.getElementById("div_sel").innerHTML=cs;
function cs(){
alert("hello");
}
</script>一段很简单的代码,我这里onclick事件不能被执行,为什么哦?
var kk="hellozhanghua";
var cs=" <select id='select1' size='40' onchange='cs()' > <option value='1''>标准标准标准 </option>
onclick可以应用在select上
你这种情况要用onchange,然后判断是不是选择的那一项
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="divsel"></div></body>
</html>
<script type="text/javascript" >var cs="<select id='select1' size='40' ><option value='1' onclick='cs1()'>标准标准标准</option><option value='2' onclick='cs1()'>标准标准标准</option></select>";
document.getElementById("divsel").innerHTML=cs;
function cs1(){
alert("hello");
}</script>
不知道各位有没有测试哦,我在火狐上是可以触发onclick事件的呀
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
</head><body>
<div id="divsel"> </div></body>
</html>
<script type="text/javascript" >var cs=" <select id='select1' size='40' onclick='csIE()' > <option value='1' onclick='cs1()'>标准标准标准 </option> <option value='2' onclick='cs1()'>标准标准标准 </option> </select>";
document.getElementById("divsel").innerHTML=cs;
function csIE(){
var oList=document.getElementById('select1');
alert(oList.options[oList.selectedIndex].firstChild.nodeValue);
}function cs1(){
alert("hello");
}
</script>
ie不支持option上的onclick,但是ff支持。ie支持select上的onclick