current position:Home>JavaScript basic learning form interlaced color change

JavaScript basic learning form interlaced color change

2022-01-27 02:35:18 Lemon flavored small fat cake

JavaScript Based on learning Form interlaced color change

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=devcie-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        table {
            width: 800px;
            margin: 100px auto;
            text-align: center;
            border-collapse: collapse;
            font-size: 14px;
        }
        
        thead tr {
            height: 30px;
            background-color: skyblue;
        }
        
        tbody tr {
            height: 30px;
        }
        
        tbody td {
            border-bottom: 1px solid #d7d7d7;
            font-size: 12px;
            color: blue;
        }
        
        .bg {
            background-color: pink;
        }
    </style>


</head>

<body>
    <table>
        <thead>
            <tr>
                <th> Code </th>
                <th> name </th>
                <th> Latest published value </th>
                <th> Cumulative net worth </th>
                <th> Net value of previous units </th>
                <th> Net worth growth rate </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th>003526 </th>
                <th> Agricultural Bank of China Jinsui 3 Open bonds regularly for months </th>
                <th>1.007</th>
                <th>1.009</th>
                <th>1.200</th>
                <th>0.800</th>
            </tr>
            <tr>
                <th>003526 </th>
                <th> Agricultural Bank of China Jinsui 3 Open bonds regularly for months </th>
                <th>1.007</th>
                <th>1.009</th>
                <th>1.200</th>
                <th>0.800</th>
            </tr>
            <tr>
                <th>003526 </th>
                <th> Agricultural Bank of China Jinsui 3 Open bonds regularly for months </th>
                <th>1.007</th>
                <th>1.009</th>
                <th>1.200</th>
                <th>0.800</th>
            </tr>
            <tr>
                <th>003526 </th>
                <th> Agricultural Bank of China Jinsui 3 Open bonds regularly for months </th>
                <th>1.007</th>
                <th>1.009</th>
                <th>1.200</th>
                <th>0.800</th>
            </tr>
        </tbody>
    </table>
    <script>
        //  obtain  tbody All the lines 
        var trs = document.querySelector('tbody').querySelectorAll('tr');
        console.log(trs.length);
        for (var i = 0; i < trs.length; i++) {
            //  Mouse over event onmouseover It will have an effect 
            trs[i].onmouseover = function() {
                    this.className = 'bg';
                }
                //  Mouse away from event onmouseout Will have an effect 
            trs[i].onmouseout = function() {
                this.className = '';
            }
        }
    </script>

</body>

</html>

 Insert picture description here

 Insert picture description here

copyright notice
author[Lemon flavored small fat cake],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270235132840.html

Random recommended