帮忙看下...很基础JS问题..谢了
<head>
<script language= "javascript ">
var objYear = document.getElementById( "Year ");
var objMonth = document.getElementById( "Month ");
var objDay = document.getElementById( "Day ");
objYear.onchange = function()
{
alert( "!! ");
}
</script>
</head>
<body>
<form>
<select id= "Year ">
<option> ONE </option>
<option> TWO </option>
</select>
<select id= "Month "> </select>
<select id= "Day "> </select>
</form>
</body>
</html>
为什么onchange没被监听到啊?~谢谢了!
------解决方案--------------------我这里可以的啊,只不过要把换个位置
<body>
<form>
<select id= "Year ">
<option> ONE </option>
<option> TWO </option>
</select>
<select id= "Month "> </select>
<select id= "Day "> </select>
</form>
<script language= "javascript ">
var objYear = document.getElementById( "Year ");
var objMonth = document.getElementById( "Month ");
var objDay = document.getElementById( "Day ");
objYear.onchange = function()
{
alert( "!! ");
}
</script>
</body>
------解决方案--------------------同意楼上的,建立监听的时候应确保你的监听对象已经建立
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<script language= "javascript ">
window.onload=function(){
var objYear = document.getElementById( "Year ");
var objMonth = document.getElementById( "Month ");
var objDay = document.getElementById( "Day ");
objYear.onchange = function(){
alert( "!! ");
}
}
</script>
</head>
<body>
<form>
<select id= "Year ">
<option> ONE </option>
<optio