<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>easyui的标签页</title> <link rel="stylesheet" type="text/css" href="css/easyui/easyui.css"> <link rel="stylesheet" type="text/css" href="css/easyui/icon.css"> <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.js"></script> </head> <body> <div id="tt" class="easyui-tabs" style="width:500px;height:250px;"> <div title="标签页1" id="tab1" style="padding:20px;display:none;"> tab1 </div> <div title="标签页2" id="tab2" style="padding:20px;display:none;"> tab2 </div> <div title="标签页3" id="tab3" data-options="selected:true" style="padding:20px;display:none;"> tab3 </div> </div> </body> <script> $(function() { //启用指定的标签页面(页面加载完成后才有效果) //方式1 $('#tt').tabs('select', 2); //方式2在div模块中添加 data-options="selected:true" });
function getInf () { $('#tt').tabs({ border:false, onSelect:function(title){ var tab = $('#tt').tabs('getSelected'); var index = $('#tt').tabs('getTabIndex',tab); alert(title+' is selected'+index); } }); }; </script> </html>
|