1. 程式人生 > >頁面切換

頁面切換

idt display solid on() mov public -type doctype html4

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<style type="text/css">
.active{
border: 1px solid red;
}
div{
width: 150px;
padding: 20px;
border: 1px solid #444;
}
</style>
<script src="js/jquery-1.12.4.js"></script>
<script src="js/jquery-migrate-1.2.0.js"></script>
<script type="text/javascript">
$(function(){
$("span").click(function(){
$(this).addClass("active").siblings().removeClass("active");
$("#center_"+$(this).index()).show().siblings("div").hide();

});
});
</script>

</head>
<body>
<span class="active">tab1</span>
<span>tab2</span>
<span>tab3</span>
<span>tab4</span>
<div id="center_0">tab1對應的內容</div>
<div id="center_1" style="display: none">tab2對應的內容</div>
<div id="center_2" style="display: none">tab3對應的內容</div>
<div id="center_3" style="display: none">tab4對應的內容</div>

</body>
</html>

頁面切換