<!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>
</head><body>
<ul>
<li onmousemove="this.childNodes[1].childNodes[0].style.display='inline'">
<a href="#">608244(天晓得) </a>
<a href="#"> <img src="images/kaixin.gif" style="display:none;" /> </a>
</li>
</ul>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<li onmousemove="this.getElementsByTagName('a')[1].style.display=''"> <a href="#">608244(天晓得) </a> <a href="#" style="display:none;"> <img src="images/kaixin.gif" /> </a> </li>
</body>
</html>
<script language="javascript">
function bian(obj){
alert(obj[1].style.display);
}
</script>
<li onmousemove="bian(this.getElementByTagName('a'))"> <a href="#" title="查看信息">608244(天晓得)</a> <a href="#" style="display:none;" title="与他聊天"> <img src="images/kaixin.gif" /> </a> </li>而且,就算是我这样,成功了,但也要为每个li都加上,onmousemove,onmouseout........天哪,有没有更简单的方法呢,直接写一个函数对所有li都起作用那种?
<!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>
</head><body>
<script type="text/javascript">
window.onload = function()
{
var list = document.getElementsByTagName("li");
for(var i=0;i<list.length;i++)
{
list[i].onmouseover=function(){
this.childNodes[1].childNodes[0].style.display=''
}
list[i].onmouseout=function(){
this.childNodes[1].childNodes[0].style.display='none';
}
}
}
</script>
<ul>
<li>
<a href="#">608244(天晓得1) </a>
<a href="#"> <img src="images/kaixin.gif" style="display:none;" /> </a>
</li>
<li>
<a href="#">608244(天晓得2) </a>
<a href="#"> <img src="images/kaixin.gif" style="display:none;" /> </a>
</li>
<li>
<a href="#">608244(天晓得3) </a>
<a href="#"> <img src="images/kaixin.gif" style="display:none;" /> </a>
</li>
<li>
<a href="#">608244(天晓得4) </a>
<a href="#"> <img src="images/kaixin.gif" style="display:none;" /> </a>
</li>
</ul>
</body>
</html>