日期:2014-05-16 浏览次数:20352 次
<!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" /> <style type="text/css"> #a_div { line-height:25px;font-weight:600;color:blue;} #a_div ul { display:none;text-decoration:none;margin:0px;} #a_div .ch_div { color:red;} #a_div ul.ch_ul { display:block;} </style> <script type="text/javascript"> start=function() { var a=document.getElementById("a_div"); var b=a.getElementsByTagName("ul"); a.onmouseover=function(){ this.className="ch_div";b.className="ch_ul";} a.onmouseout=function(){ this.className="";b.className="";} } window.onload=start; </script> </head> <body> <div id="a_div" >导航 <ul> <li>内容1</li> <li>内容2</li> </ul> </div> </body> </html>
// var b = a.getElementsByTagName("ul"); var b = a.getElementsByTagName("ul")[0];