jquery选项卡

功能介绍:

1.鼠标划过当前按钮,当前按钮变色

2.对应图片展示

3.鼠标划过其他按钮,对应图片出现,其他按钮变回原色,其他图片隐藏

所有代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选项卡2</title>
    <style>
        body, div, dl, dt, dd, ul, li, h1, h2, h3, h4, h5, h6, code, form, input, textarea, p, th, td, fieldset, legend, figure {
            margin: 0;
            padding: 0;
        }

        body {
            font-family: "微软雅黑", Arial;
        }

        ul, ol {
            list-style: none;
        }

        a {
            text-decoration: none;
        }

        img {
            border: 0;
        }

        .uls1 {
            width: 500px;
            height: 40px;
            background: #2ba0db;
        }

        .uls1 li {
            width: 99px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            float: left;
            cursor: pointer;
            border-right: 1px solid black;
            color: white;
        }

        .box {
            width: 500px;
            height: 400px;
            margin: 100px auto;
            position: relative;
        }

        .uls2 li {
            position: absolute;
            top: 40px;
        }

        .uls2 li img {
            width: 500px;
            height: 400px;
            float: left;
        }

        .cur {
            background: #282c34;
        }
    </style>
<body>
<div class="box">
    <ul class="uls1">
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
    </ul>
    <ul class="uls2">
        <li><img src="img/1.jpg" alt=""></li>
        <li><img src="img/2.jpg" alt=""></li>
        <li><img src="img/3.jpg" alt=""></li>
        <li><img src="img/4.jpg" alt=""></li>
        <li><img src="img/5.jpg" alt=""></li>
    </ul>
</div>
</body>
</html>
<script src="js/jquery-1.8.3.min.js"></script>
<script>
    var child = $(".uls1").children("li");
    var child2 = $(".uls2").children("li");
    $(child).mouseover(function () {
        $(child).eq($(this).index()).addClass("cur").siblings().removeClass('cur');
        $(child2).hide().eq($(this).index()).show();
    });
</script>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值