JS case four: interlacing and highlighting of tables

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script>
            window.onload = function() {
                var oldColor;
                var tblEle = document.getElementById("tbl");
                var len = tblEle.tBodies[0].rows.length;
                for(var i = 0;i<len;i++) {
                    if(i%2==0) {
                        tblEle.tBodies[0].rows[i].style.backgroundColor = "pink";
                        //Adding mouse passesTblEle.tBodies[0].rows[i].onmouseover = function () {OldColor = this.style.backgroundColor;This.style.backgrouNdColor = "blue";}/ / add mouse to leave eventTblEle.tBodies[0].rows[i].onmouseout = function () {This.style.backgRoundColor = oldColor;}}else{TblEle.tBodies[0].rows[i].style.backgroundColor = "gold";/ / add mouse event.TblEle.tBodies[0].rows[i].onmouseover = function () {OlDColor = this.style.backgroundColor;This.style.backgroundColor = "blue";}/ / add mouse to leave eventTblEle.tBodiEs[0].rows[i].onmouseout = function () {This.style.backgroundColor = oldColor;}}}}< /Script>< /head>< body>< table id= "TBL" border= "1" border-collapse="Collapse" align= "center" cellspacing= "0" cellpadding= "5" width= "400" height= "20" >&lT; thead>< tr>< th> Numbering < /th> < th> name < /tH> < th> age < /th>< /tr>< /thead><Tbody>< tr>< td> 1< /td>< td> Zhang three < /td>< td> 12< /td>< /tr>< tr>< td> 2< /td>< td> Lee four &lT; /td>< td> 22< /td>< /tr>&lT; tr>< td> 3< /td>< td> Wang five < /td>< td> 13< /td>< /tr>< tr>< td> 4< /td>< td> Ma six < /td>< td> 14< /td>< /tr>< tr>< td> 5< /td>< td> Wu Liu Qi < /td>< td> 17< /td>< /tr>< tr>< td> 6≪ /td>< td> plum blossom thirteen < /td>< td> 17< /td>< /tr>< /tbody>< /table>< /body></html>

Leave a Reply

Your email address will not be published. Required fields are marked *