点击按钮的时候,被点击按钮颜色变化,其他按钮要保持不变。

<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]>      <html class="no-js"> <!--<![endif]-->
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <style>
            div {
                width: 370px;
                margin: 100px auto;

            }
        </style>
        <script src="jquery.min.js"></script>
    </head>
    <body>
        <div >
            <button>我是一号</button>
            <button>我是二号</button>
            <button>我是三号</button>
            <button>我是四号</button>
            <button>我是五号</button>
        </div>
        <script>
            $(function() {
                $("button").click(function() {
                    $(this).css("background", "gray");
                    $(this).siblings("button").css("background", "");
                });
            })

        </script>
    </body>
</html>

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

插入图片