jquery事件切换

原创 2019-04-12 10:25:46 215
摘要:<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <title>Document</title>    <script src="https://cdn.staticf

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

   <style type="text/css">

        div{width: 300px;height: 500px; background-color:blue;}

        p{width: 300px;height: 500px; background-color:blue;}

    </style>

</head>

<body>

    <script type="text/javascript"> 

        $(document).ready(function(){

        // $('div').hover(

        //     function(){

        //         $(this).css('background','red');

        //     },

        //     function(){

        //         $(this).css('background','#fff')

        //     }

        //     )

        $('button').click(function(){

            $('p').toggle().css('background','red');

        })

        });

</script>

        <div>现实的</div>

        <p></p>

        <button>点击</button>

</body>

</html>


批改老师:天蓬老师批改时间:2019-04-12 11:08:01
老师总结:如果是要控制元素的样式,使用css方法, 建议用对象字面量参数

发布手记

热门词条