请教Javascript关于onmouseover事件的问题
<html><head> <title>test</title> <style> ul li{ float:left; } </style></head><body> <ul id="myul"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> <script language="javascript"> var nodes = this.myul.childNodes; for (var i = 0 ; i < nodes.length ; i++ ){ var node = nodes[i]; node.onmouseover = function() { node.style.backgroundColor = "red"; } } </script></body></html>
var nodes = this.myul.childNodes; for (var i = 0 ; i < nodes.length ; i++ ){ var node = nodes[i]; node.onmouseover = function() { this.style.backgroundColor = "red"; } node.onmouseout = function() { this.style.backgroundColor = "transparent"; } }