htmltable 태그 마우스 이동 배경 변색

8884 단어 HTML

<html>
 <head>
  <title> new document title>  
  <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>   
  <script type="text/javascript"> 
  
      window.onload = function(){
                  
     //  , 。
        var trs = document.getElementsByTagName("tr");
        for(var tr of trs){
            tr.onmouseover = function(){
                this.style.backgroundColor = "#f2f2f2";
            }
            tr.onmouseout = function(){
                this.style.backgroundColor = "#fff";
            }
        }
	 }
  script> 
 head> 
 <body> 
	   <table border="1" width="50%" id="table">
	   <tr>
		<th> th>
		<th> th>
		<th> th>
	   tr>  

	   <tr>
		<td>xh001td>
		<td> td>
	   tr>

	   <tr>
		<td>xh002td>
		<td> td>
	   tr>  

	   table>
 body>
html>

좋은 웹페이지 즐겨찾기