帮忙看一下怎么不可以啊,谢谢 <!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"> body,ul,li{ list-style: none; margin: 0; padding: 0;} li{ width: 200px; height: 200px; background:red; margin-bottom:1px; filter:alpha(opacity:30);opacity:0.3; float:left; margin-right:10px;} </style> </head> <body> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </body> </html> <script type="text/javascript"> var ali = document.getElementsByTagName('li'); for (var i = 0; i < ali.length; i++) { ali[i].timer = null; ali[i].alpha = 30; ali[i].onmouseover = function(){ opty(this,100); } ali[i].onmouseout = function(){ opty(this,30); } }; //var timer = null; //var alpha =0 ; function opty(obj,iTarget){ obj.timer = setInterval(function(){ var speed = 0; if(obj.alpha>iTarget){ speed = -5; }else{ speed = 5; }; if(obj.alpha == iTarget){ clearInterval(obj.timer); }else{ obj.alpha+=speed; obj.style.filter = 'alpha(opacity:'+obj.alpha+')'; obj.style.opacity = obj.alpha/100; } },30) } </script>
帮忙看一下怎么不可以啊,谢谢