<html>
<head>
<title>切换tab</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />
<script src="../../scripts/boot.js" type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body οnlοad="displaystudentOneTab()">//页面加载完自动执行displaystudentOneTab方法,默认显示第一个tab
<form id="studentForm" name="studentForm" method="post" style="margin:0 -10px">
<table style="width:100%;margin-top:20px;" cellspacing="1" cellpadding="1" border="0" align="center">
<tr>
<td>
<table id="tabTable">
<tr>
<td id="studentOneTab" οnclick="displaystudentOneTab()">
第一个tab
</td>
<td id="studentTwoTab" οnclick="displaystudentTwoTab();">
第二个tab
</td>
<td id="studentThreeTab" οnclick="displaystudentThreeTab()">
第三个tab
</td>
<td id="studentTourTab" οnclick="displaystudentTourTab()">
第四个tab
</td>
</tr>
</table>
</td>
</tr>
</table>
<div id="studentOneDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_one">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小明"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="21" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentTwoDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_two">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小张"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="217" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q140" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentThreeDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_three">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小芳"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="女" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="23" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentTourDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_one">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小辉"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="21" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
function displaystudentTwoTab() {
$("#studentTwoDiv").show();//选中的显示,其余的隐藏
$("#studentTwoTab").css({"background-color":"#50ffba"});//加以颜色区分
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentThreeDiv").hide();
$("#studentTourDiv").hide();
$("#studentOneDiv").hide();
}
function displaystudentThreeTab() {
$("#studentTwoDiv").hide();
$("#studentThreeDiv").show();
$("#studentThreeTab").css({"background-color":"#50ffba"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentTourDiv").hide();
$("#studentOneDiv").hide();
}
function displaystudentTourTab() {
$("#studentTwoDiv").hide();
$("#studentThreeDiv").hide();
$("#studentTourDiv").show();
$("#studentTourTab").css({"background-color":"#50ffba"});
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentOneDiv").hide();
}
function displaystudentOneTab() {
$("#studentOneDiv").show();
$("#studentOneTab").css({"background-color":"#50ffba"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentTwoDiv").hide();
$("#studentThreeDiv").hide();
$("#studentTourDiv").hide();
}
</script>
</body>
</html>
<head>
<title>切换tab</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" />
<script src="../../scripts/boot.js" type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body οnlοad="displaystudentOneTab()">//页面加载完自动执行displaystudentOneTab方法,默认显示第一个tab
<form id="studentForm" name="studentForm" method="post" style="margin:0 -10px">
<table style="width:100%;margin-top:20px;" cellspacing="1" cellpadding="1" border="0" align="center">
<tr>
<td>
<table id="tabTable">
<tr>
<td id="studentOneTab" οnclick="displaystudentOneTab()">
第一个tab
</td>
<td id="studentTwoTab" οnclick="displaystudentTwoTab();">
第二个tab
</td>
<td id="studentThreeTab" οnclick="displaystudentThreeTab()">
第三个tab
</td>
<td id="studentTourTab" οnclick="displaystudentTourTab()">
第四个tab
</td>
</tr>
</table>
</td>
</tr>
</table>
<div id="studentOneDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_one">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小明"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="21" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentTwoDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_two">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小张"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="217" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q140" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentThreeDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_three">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小芳"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="女" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="23" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
<div id="studentTourDiv" style="width:100%;margin: 0 auto;display:none"><table border="1" style="width:50%;" id="class_one">
<tr>
<td>姓名</td>
<td><input name="editName" id="editName" value="小辉"/></td>
</tr>
<tr>
<td>性别</td>
<td><input name="editGender" id="editGender" value="男" /></td>
</tr>
<tr>
<td >年龄</td>
<td><input name="editAge" id="editAge" value="21" /></td>
</tr>
<tr>
<td >学号</td>
<td><input name="editNumber" id="editNumber" value="Q100" /></td>
</tr>
<tr>
<td>
<span>
<a href="#" id="addStudent" οnclick="add_Student(this);return false;">添加</a>
</span>
</td>
</tr>
</table></div>
</form>
JS部分:
<script type="text/javascript">function displaystudentTwoTab() {
$("#studentTwoDiv").show();//选中的显示,其余的隐藏
$("#studentTwoTab").css({"background-color":"#50ffba"});//加以颜色区分
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentThreeDiv").hide();
$("#studentTourDiv").hide();
$("#studentOneDiv").hide();
}
function displaystudentThreeTab() {
$("#studentTwoDiv").hide();
$("#studentThreeDiv").show();
$("#studentThreeTab").css({"background-color":"#50ffba"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentTourDiv").hide();
$("#studentOneDiv").hide();
}
function displaystudentTourTab() {
$("#studentTwoDiv").hide();
$("#studentThreeDiv").hide();
$("#studentTourDiv").show();
$("#studentTourTab").css({"background-color":"#50ffba"});
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentOneTab").css({"background-color":"#F5F5F5"});
$("#studentOneDiv").hide();
}
function displaystudentOneTab() {
$("#studentOneDiv").show();
$("#studentOneTab").css({"background-color":"#50ffba"});
$("#studentTourTab").css({"background-color":"#F5F5F5"});
$("#studentThreeTab").css({"background-color":"#F5F5F5"});
$("#studentTwoTab").css({"background-color":"#F5F5F5"});
$("#studentTwoDiv").hide();
$("#studentThreeDiv").hide();
$("#studentTourDiv").hide();
}
</script>
</body>
</html>