如何用jQuery实现页面的菜单跳转

lianrouwupan 2016-11-26 06:29:50
一个页面,左边有菜单栏,右边有相应的栏目。由于栏目的内容比较多。浏览器每次只会显示一个栏目的内容,如何通过jquery实现当点击某个菜单栏。右边会跳到相应的栏目?
...全文
409 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lianrouwupan 2016-11-27
  • 打赏
  • 举报
回复
引用 3 楼 chinmo 的回复:
苗点可以实现的,为何要用JQ?给自己找麻烦?
想多学点东西。
  • 打赏
  • 举报
回复
苗点可以实现的,为何要用JQ?给自己找麻烦?
lianrouwupan 2016-11-26
  • 打赏
  • 举报
回复
引用 1 楼 zzgzzg00 的回复:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
        div{
            height: 300px;
            box-sizing: border-box;
        }
        .left{
            width: 200px;
        }
        .left a{
            display: inline-block;
            width: 100%;
            text-align: center;
        }
        .right{
            flex:1;
            overflow: hidden;
            border-left: 1px solid #ff0000;
        }
        .container{
            display: flex;
            width: 100%;
        }
        .right>div{
            line-height: 300px;
            background-color: #ffff00;
            text-align: center;
        }
        .right>div:nth-of-type(2n){
            background-color: gray;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="left">
            <a href="#test1">test1</a>
            <a href="#test2">test2</a>
            <a href="#test3">test3</a>
        </div>
        <div class="right">
            <div id="test1">test1</div>
            <div id="test2">test2</div>
            <div id="test3">test3</div>
        </div>
    </div>
    <script>

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

锚点就可以把
是可以。jQuery应该也能实现吧?
似梦飞花 2016-11-26
  • 打赏
  • 举报
回复

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
        div{
            height: 300px;
            box-sizing: border-box;
        }
        .left{
            width: 200px;
        }
        .left a{
            display: inline-block;
            width: 100%;
            text-align: center;
        }
        .right{
            flex:1;
            overflow: hidden;
            border-left: 1px solid #ff0000;
        }
        .container{
            display: flex;
            width: 100%;
        }
        .right>div{
            line-height: 300px;
            background-color: #ffff00;
            text-align: center;
        }
        .right>div:nth-of-type(2n){
            background-color: gray;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="left">
            <a href="#test1">test1</a>
            <a href="#test2">test2</a>
            <a href="#test3">test3</a>
        </div>
        <div class="right">
            <div id="test1">test1</div>
            <div id="test2">test2</div>
            <div id="test3">test3</div>
        </div>
    </div>
    <script>

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

锚点就可以把

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧