A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

本帖最后由 追寻Dream 于 2013-10-20 16:30 编辑

<!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=utf-8" />
<title>无标题文档</title>
      
<style type="text/css">
h1{background:blue;}

.blue{ background:red;}
</style>
   
<script type="text/javascript">
window.onload=function(){
var main=document.getElementById('main');{
  main.onmouseover=function(){
  this.className="blue";
  }
  main.onmousemove=function(){
  this.className="";
   }
  
  }

}
        
</script>  
</head>
<body >

<h1 id="main">网站导航</h1>
  
</body>
</html>
怎么实现不了动态交互功能,求指导?

2 个回复

倒序浏览
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>无标题文档</title>
  6. <style type="text/css">
  7. h1 {
  8.         background:blue;
  9. }
  10. .blue {
  11.         background:red;
  12. }

  13. </style>
  14. <script type="text/javascript">
  15. window.onload=function()
  16. {
  17.         var main=document.getElementById('main');

  18.                    main.onmouseover=function()
  19.                 {
  20.                    this.className="blue";

  21.                   }
  22.                    main.onmouseout=function()
  23.                 {
  24.                    this.className="";
  25.                            
  26.                 }

  27. }
  28.          
  29. </script>
  30. </head>
  31. <body >
  32. <h1 id="main">网站导航</h1>
  33. </body>
  34. </html>
复制代码
onmouseout才是离开

评分

参与人数 1技术分 +2 收起 理由
追溯客 + 2

查看全部评分

回复 使用道具 举报
如问题被解决,请及时把分类设为"已解决",黑马有你更精彩!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马