<%@ page language="java" contentType="text/html; charset=gb2312"
     pageEncoding="UTF-8"%>
    <%request.setCharacterEncoding("GB2312");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<script language="JavaScript" type="text/JavaScript">
function handle()
{

alert(document.getElementById("xyz123").width);   

alert(document.getElementById("xyz123").bgcolor); 
       // 这句输出一个undifined,为什么 不能访问和修改其中的bgcolor。。崩溃
}
</script>
</head><body  id = "uuu" bgcolor = "lightblue" onload="handle();">
<table id = "xyz123" height="30" width="150"  bgcolor="red" border="2">
<tr bordercolor="yellow" height="30" onmouseover="handle();" >
<th rowspan="2" >学生基本信息查询</th>
</tr>
</table></body>
</html>请路过大侠 讲解一下啊。

解决方案 »

  1.   

    document.getElementById("xyz123").getAttribute('bgcolor')
      

  2.   

    document.getElementById("xyz123").getAttribute('bgcolor')
      

  3.   

    document.getElementById("xyz123").bgColor要大写
      

  4.   

    alert(document.getElementById("xyz123").attributes[3].nodeValue);
      

  5.   

    修改一下:
    <table id = "xyz123" height="30" width="150" style="bgcolor:red" border="2">alert(document.getElementById("xyz123").style.bgcolor);