不說空話了,很簡單,直接上代碼。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf⑻" />
<title>無標題文檔</title>
<script type="text/javascript" src="jquery⑴.11.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#btn").unbind().click(function(){
$("#first").hide();
$("#sec").css("left","⑵00px").animate({"left":"0px"},500).show();
});
$("#btn2").unbind().click(function(){
$("#sec").hide();
$("#first").css("left","200px").animate({"left":"0px"},500).show();
});
$("#btn3").unbind().click(function(){
$("#first").hide();
$("#sec").css("top","200px").animate({"top":"0px"},500).show();
});
$("#btn4").unbind().click(function(){
$("#sec").hide();
$("#first").css("top","⑵00px").animate({"top":"0px"},500).show();
});
});
</script>
</head>
<body>
<div style="width:200px; height:200px;">
<div id="first" style="text-align:center; width:200px; height:200px;position:absolute;">
<p>第1頁</p>
<p>第1頁</p>
<p>第1頁</p>
<p>第1頁</p>
<p>第1頁</p>
</div>
<div id="sec" style="text-align:center; width:200px; height:200px; display:none;position:absolute;">
<p>第2頁</p>
<p>第2頁</p>
<p>第2頁</p>
<p>第2頁</p>
<p>第2頁</p>
</div>
</div>
<div style="width:200px; height:50px;">
<input type="button" value="向右轉動" id="btn"/>
<input type="button" value="向左轉動" id="btn2"/>
<input type="button" value="向上轉動" id="btn3"/>
<input type="button" value="向下轉動" id="btn4"/>
</div>
</body>
</html>
特別要注意:標紅的地方1定要加上,否則不會出現效果。
下一篇 思科CCNA第一學期第八章答案