简单教程
提交运行
代码编辑器:
<!DOCTYPE htm> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> <style>body {margin:20px}</style> <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">第 1 部分 (点我进行展开,再次点我进行折叠) </a> </h4> </div> <div id="collapseOne" class="panel-collapse collapse in"> <div class="panel-body">只要用心为用户挖掘想要的功能,这些不谋而合的想法就会不断出现 </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">第 2 部分 (点我进行展开,再次点我进行折叠) </a> </h4> </div> <div id="collapseTwo" class="panel-collapse collapse"> <div class="panel-body">只要用心为用户挖掘想要的功能,这些不谋而合的想法就会不断出现 </div> </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">第 3 部分 (点我进行展开,再次点我进行折叠) </a> </h4> </div> <div id="collapseThree" class="panel-collapse collapse"> <div class="panel-body">只要用心为用户挖掘想要的功能,这些不谋而合的想法就会不断出现 </div> </div> </div> </div> <script> $(function(){ $('#collapseFour').collapse({toggle:false}); $('#collapseTwo').collapse('show')}); $('#collapseThree').collapse('toggle')}); $('#collapseOne').collapse('hide'); }); </script> <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script> <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
运行结果: