JS技术

Javascript教程_新闻列表鼠标滑过,显示单条详情的js_Javascript教程

字号+ 作者:H5之家 来源:H5之家 2015-09-27 12:19 我要评论( )

Javascript教程_新闻列表鼠标滑过,显示单条详情的js,学习Javascript教程_新闻列表鼠标滑过,显示单条详情的js,Javascript教程_新闻列表鼠标滑过,显示单条详情的js

<script type="text/javascript">
(function(oList){
    for (var i=0;i<=oList.length;i++){
    var obj=document.getElementById(oList[i]);
    var liObj=obj.getElementsByTagName("li");
    var length=liObj.length;
    for(var i=0;i<length;i++){
        liObj[i].onmouseover=function(){
            this.className+=" hover";
        }
        liObj[i].onmouseout=function(){
            this.className=this.className.replace('hover','');
        }
    }
    }
})([ID1,ID2,ID3...,IDN]);
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<style type="text/css">
body { font-size:12px; }
ul, h2, p { margin:0; padding:0; }
.list { list-style:none; width:400px; position:relative; vertical-align:middle; }
.list li { border-bottom:solid 1px #eee; cursor:default; position:relative; width:100%; }
.list h2 { font-size:100%; font-weight:normal; padding:.5em;}
.list span { position:absolute; right:1em; top:.5em; font-family:Verdana; font-size:90%;}
.list div { display:none; position:relative; height:70px; }
.list div img { float:left; margin:.8em 1em; background:#6FF; }
.list div p { padding:.8em; }
.list div p strong { display:block; margin-bottom:.5em; }
.list li:hover, .list li.hover { height:auto; }
.list li:hover div, .list li.hover div { display:block; }
.list li:hover h2, .list li.hover h2, .list li:hover span, .list li.hover span { background:#5B86BB; color:#fff; }
</style>
</head>
<body>
<ul class="list" id="demo">
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
</ul>
<ul class="list" id="demo1">
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
 <li>
  <h2>蓝色理想之经典论坛</h2>
  <span>2010-04-19</span>
  <div> <img src="" alt="" width="100" height="50" />
   <p><strong>蓝色理想之经典论坛</strong>大家都来经典论坛积极交流吧!</p>
  </div>
 </li>
</ul>
</body>
</html>
<script type="text/javascript">
(function(oList){
    for (var i=0;i<=oList.length;i++){
 var obj=document.getElementById(oList[i]);
 var liObj=obj.getElementsByTagName("li");
 var length=liObj.length;
 for(var i=0;i<length;i++){
  liObj[i].onmouseover=function(){
   this.className+=" hover";
  }
  liObj[i].onmouseout=function(){
   this.className=this.className.replace('hover','');
  }
 }
    }
})(["demo","demo1"]);
</script>

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
网友点评