H5基础知识第十四课时(用JQuery实现鼠标悬浮时改变样式)

html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>鼠标悬浮时改变样式title>
    <style>
        #div1{
            width: 300px;
            height: 500px;
            display: flex;
            justify-content: center;
            color: white;
        }
        .a{
            width: 100px;
            height: 40px;
            background-color: #cccccc;
            border: 1px solid #cccccc;
            margin: 1px;
            border-radius: 25px 25px 0px 0px;
            line-height: 40px;
            text-align: center;
        }

    style>
head>
<body>
<div id="div1">
    <div class="a">左侧DIVdiv>
    <div class="a">中间DIVdiv>
    <div class="a">右侧DIVdiv>
div>
body>
<script src="../../js/jquery-3.1.1.min.js">script>
<script>
    $("#div1 div:first-child").mouseover(function () {
       $(this).css("background-color","red");

    }).mouseout(function () {
        $(this).css("background-color","#cccccc");
    })
    $(" div + div").mouseover(function () {
       $(this).css("background-color","red");
    }).mouseout(function () {
        $(this).css("background-color","#cccccc");
    })
    $("#div1 div:last-child").mouseover(function () {
        $(this).css("background-color","red");
    }).mouseout(function () {
        $(this).css("background-color","#cccccc");
    })
script>



html>

你可能感兴趣的:(H5基础知识第十四课时(用JQuery实现鼠标悬浮时改变样式))