铭瑶学习社区

首页 » 网站建设(编程语言) » HTML/CSS » 鼠标划过通过CSS图层变色
haiou - 2008-11-4 20:45:00
<!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" c />
<title>无标题文档</title>
<style type="text/css">
      <!--
      #test1{
          width:50%;
          margin:0px auto;
          padding:5px;
      }
      .border1{
          background:#ADE9AE ;
          border:dotted 1px #ff0000;
      }
      .border2{
          background:#ffffff;
          border:solid 1px #00ff00;
      }
      -->
</style>
<script type="text/javascript">
function changeColor(){
  var test;
  test=document.getElementById("test1");
  test.onmouseover=function(){
  test.className='border1';
  }
  test.onmouseout=function(){
  test.className='border2';
  }
}
window.onload=changeColor;
</script>
</head>
<body>
<div id="test1" class="border2">
          getElementById(参数)---根据页面项目的id,取得该对象,对象是唯一的。getElementsByName(参数)---根据页面项目的名字,取得对象集合。
        </div>
</body>
</html>
yunt - 2008-11-9 0:19:00
:Z1 :Z1 :Z1 :Z1
1
查看完整版本: 鼠标划过通过CSS图层变色