zoukankan      html  css  js  c++  java
  • 问题是:js是如何实现鼠标移动到不同栏位切换对应的显示内容的?

    最佳答案
     

    给你一个示例代码吧,引用了jQuery框架。你可以将这个js文件下载到本地或直接使用例子中的远程地址(不过由于国内google经常访问不了建议下载下来)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    <!DOCTYPE HTML>
    <html>
    <head>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript">
            function switchContentBox(obj) {
                obj = $(obj);
                var contentBox = obj.parents('div.box:first').children('div.content');
                var index = obj.attr('item');
                contentBox.children().hide();
                contentBox.children(':eq(' + index + ')').show();
            }
        </script>
    </head>
    <body>
    <div class="box">
        <div class="title">
            <span item="0" onmouseover="switchContentBox(this)">Demo1</span>
            <span item="1" onmouseover="switchContentBox(this)">Demo2</span>
        </div>
        <div class="content">
            <div>Content of Demo1</div>
            <div style="display: none;">Content of Demo2</div>
        </div>
    </div>
    </body>
    </html>
  • 相关阅读:
    3.2 直线与方程
    3.1.2 两条直线平等与垂直的判定
    GNU Make
    linux 启动后台进程
    go 占位符
    raft 协议
    restTemplate 接收list数据
    JAVA通过实体类生成数据库查询语句(驼峰命名规则)
    flink使用命令开始、停止任务
    SPringBoot 配置类继承WebMvcConfigurationSupport和实现WebMvcConfigurer的使用
  • 原文地址:https://www.cnblogs.com/proving/p/8303100.html
Copyright © 2011-2022 走看看