描述:用户鼠标经过某一张图片的时候,该图片高亮显示,与之相同的图片颜色变暗。鼠标离开后,恢复为原来的样子。jQuery的版本为1.8。本代码不提供图片,如果需要图片的可以给小编留言。
示例代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>高亮显示图片</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
        }

        body {
            background: #000;
        }

        .wrap {
            margin: 100px auto 0;
            width: 630px;
            height: 394px;
            padding: 10px 0 0 10px;
            background: #000;
            overflow: hidden;
            border: 1px solid #fff;
        }

        .wrap li {
            float: left;
            margin: 0 10px 10px 0;

        }

        .wrap img {
            display: block;
            border: 0;
        }
    </style>
    <script src="../jquery.min.js"></script>
    <script>
        $(function () {
            $(".wrap").find("li").mouseenter(function () {
                $(this).css("opacity",1).siblings("li").css("opacity",0.4);
            });
            $(".wrap").mouseleave(function () {
                $(this).children().children("li").css("opacity",1);
            });

        })
    </script>
</head>
<body>
<div class="wrap">
    <ul>
        <li><a href="#"><img src="images/01.jpg" alt=""/></a></li>
        <li><a href="#"><img src="images/02.jpg" alt=""/></a></li>
        <li><a href="#"><img src="images/03.jpg" alt=""/></a></li>
        <li><a href="#"><img src="images/04.jpg" alt=""/></a></li>
        <li><a href="#"><img src="images/05.jpg" alt=""/></a></li>
        <li><a href="#"><img src="images/06.jpg" alt=""/></a></li>
    </ul>
</div>
</body>
</html>
Last modification:May 4, 2018
If you think my article is useful to you, please feel free to appreciate