23 July 2017

JQuery: Tạo css background cho thẻ tr bằng thuộc tính tr:even với HTML + JQuery

JQuery tạo css background cho thẻ tr even
JavaScript 2017

<!DOCTYPE html>
<html>
    <head>
        <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
        <script>
            $(document).ready(function () {
                $("tr:even").css("background-color", "yellow");
            });
        </script>
    </head>
    <body>

        <h1>Welcome to My Web Page</h1>

        <table border="1">
            <tr>
                <th>Company</th>
                <th>Country</th>
            </tr>
            <tr>
                <td>Alfreds Futterkiste</td>
                <td>Germany</td>
            </tr>
            <tr>
                <td>Berglunds snabbköp</td>
                <td>Sweden</td>
            </tr>
            <tr>
                <td>Centro comercial Moctezuma</td>
                <td>Mexico</td>
            </tr>
            <tr>
                <td>Ernst Handel</td>
                <td>Austria</td>
            </tr>
            <tr>
                <td>Island Trading</td>
                <td>UK</td>
            </tr>
        </table>

    </body>
</html>

0 nhận xét:

Post a Comment

 

BACK TO TOP

Xuống cuối trang