jQuery练习t197,从0到1

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .select{
            color: blue;
            background-color: #F1F1F1;
            font-weight: bold;
        }
    </style>
    <script src="../js/jquery-3.5.1.js"></script>
    <script>
        $(function () {
            //样式操作,添加class
            //$().addClass("类名");
           $("#btn1").click(function () {
               $("li:nth-child(odd)").addClass("select");
           });
        });
    </script>
</head>
<body>
    <ul>
        <li>HTML</li>
        <li>CSS</li>
        <li>Javascript</li>
        <li>jQuery</li>
        <li>Vue.js</li>
    </ul>
    <input type="button" id="btn1" value="添加">
</body>
</html>

 

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:C马雯娟 返回首页