• Jquery 通过 data- 来实现按钮点击切换显示隐藏


    +Tenus One <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags must come first in the head; any other head content must come after these tags -->
        <title>Bootstrap 101 Template</title>
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
      <style type="text/css">
    
      .jumbotron {text-align: center;}
      </style>
    
        <!-- Bootstrap -->
        <link href="css/bootstrap.min.css" rel="stylesheet">
    
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
      </head>
      <body>
    <div class="container">
      <div class="jumbotron">
        <h1>Let's have Fun</h1>      
        <button type="button"  class="btn btn-default panel-button" data-panelid="panel1">#btn1</button>
        <button type="button"  class="btn btn-default panel-button" data-panelid="panel2">#btn2</button>
        <button type="button"  class="btn btn-default panel-button" data-panelid="panel3">#btn3</button>
        <button type="button"  class="btn btn-default panel-button" data-panelid="panel4">#btn4</button>
      </div>
      <div class="col-xs-3">
      <div id="panel1" class="panel panel-primary">
      <div class="panel-heading">
       #panel1
      </div>
      <div class="panel-body"> Contet 
      </div>
    
      </div>
      </div>
      <div class="col-xs-3">
      <div id="panel2" class="panel panel-primary">
      <div class="panel-heading">
       #panel2
      </div>
      <div class="panel-body"> Contet 
      </div>
    
      </div>
      </div>
      <div class="col-xs-3">
      <div id="panel3" class="panel panel-primary">
      <div class="panel-heading">
       #panel3
      </div>
      <div class="panel-body"> Contet 
      </div>
    
      </div>
      </div>
      <div class="col-xs-3">
      <div id="panel4" class="panel panel-primary">
      <div class="panel-heading">
       #panel4
      </div>
      <div class="panel-body"> Contet 
      </div>
    
      </div>
      </div>
        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <!-- <script src="js/bootstrap.min.js"> -->
    <script type="text/javascript">
        $(function(){
            var content="My New Awesome Content";
            $('.panel-button').on('click',function(){
                var panelId=$(this).attr('data-panelid');
                $('#'+panelId).toggle();
                
                // 添加内容
                $('#'+panelId+' .panel-body').html('');
            })
        })
    </script>
        
    
      
      </body>
    </html>
  • 相关阅读:
    EasyUI Combobox组合框(模糊搜索、默认值绑定)
    Asp.Net下载文件时中途失败问题
    VS使用小技巧之——设置调试时启动项目和启动页
    VS使用小技巧之——给代码添加region
    VS使用小技巧之——引入整个文件夹
    VS使用小技巧之——任务列表
    FineUI给表格行内链接设置弹出窗体
    cnpm私服搭建和发布包
    阿里云产品术语和docker
    angularjs1.x的一些知识点整理
  • 原文地址:https://www.cnblogs.com/hechunfeng/p/15258146.html
Copyright © 2020-2023  润新知