1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title>Title</title>67<body>8<table border= "1" width= "480px" >9<tr><td>1</td><td>2</td><td>3</td></tr>Ten<tr><td>1</td><td>2</td><td>3</td></tr> One<tr><td>1</td><td>2</td><td>3</td></tr> A</table> -<script> - varMytrs = document.getElementsByTagName (' tr ')//The return value is a list, the varLen =mytrs.length; - for(i=0;i<len;i++) {//Loop This list to get each TR and add attributes to him -Mytrs[i].onmouseover =function() {//onmouseover= function () is the cursor moving to a location to execute this anonymous - This. Style.backgroundcolor = ' Red '//This is the meaning of this function, which refers to which label + }; - + A atMytrs[i].onmouseout =function() {//onmouseout = function () is the cursor moving to a location to execute this anonymous function - This. style.backgroundcolor= ' - }; - - } -</script> in</body> -Effects such as:
Use DOM1 to achieve, according to the cursor movement automatically add background color to the form, the cursor removed automatically remove the background color