HTML对象.innerHTML
名称:name
在HTML的标签中,除了表单元素有name属性外,其它的HTML标签都没有name属性,只有id属性。
·通过id获取HTML元素:document.getElementById( id标识 )
通过此种方法获取文本框的值:document.getElementById( 文本框id ).value
·CSS样式里的display属性:值为none时,则隐藏,值为""时,则显示
今天要掌握的内容:
·HTML对象.innerHTML
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>后台管理框架</title>
<script language="javascript" type="text/javascript">
function close_dh()
{
// 关闭左边的栏目导航
document.getElementById("dh").style.display = "none" ;
// 切换图片
document.getElementById("aaa").innerHTML = "<img src=\"images/right_arrow.jpg\" onclick=\"open_dh();\" />";
}
function open_dh()
{
// 打开左边的栏目导航
document.getElementById("dh").style.display = "" ;
// 切换图片
document.getElementById("aaa").innerHTML = "<img src=\"images/left_arrow.jpg\" onclick=\"close_dh();\" />";
}
</script>
</head>
<body>
<table width="80%" height="409" border="1" align="center">
<tr>
<td id="dh" width="22%" align="center">
<p>首页</p>
<p>体育新闻</p>
<p>经济新闻</p>
<p>娱乐新闻</p>
<p>科技新闻</p>
<p>栏目一</p>
<p>栏目二</p>
<p>栏目三</p>
</td>
<td id="aaa" width="1%">
<img src="images/left_arrow.jpg" onclick="close_dh();" />
</td>
<td width="77%" align="center"><h1>主体内容</h1></td>
</tr>
</table>
</body>
</html>
浙公网安备 33010602011771号