jquery 實現簡單的切圖

<!DOCument html>
<html lang="zh_CN">
<head>
<style>
.div{width:500px; height:400px;border:1px red solid;margin:0 auto;}
</style>
<script src="jquery/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('p#n1').hide();
$('p#n2').hide();
$("button.a1").click(function(){
$('p#n1').hide();
$('p#n2').hide();
$('p#n3').show();
});
$("button.a2").click(function(){
$('p#n1').show();
$('p#n2').hide();
$('p#n3').hide();
});
$("button.a3").click(function(){
$('p#n1').hide();
$('p#n2').show();
$('p#n3').hide();
});

});
</script>
</head>
<body>
<div class="div">
<p id="n1"><img src="./images/2.jpg" width="499px;" height="400px"></p>
<p id="n2"><img src="./images/5.jpg" width="499px;" height="400px;"></p>
<p id="n3"><img src="./images/1.jpg" width="499px;" height="400px;"></p>
</div>
<button class="a1">第一張</button>
<button class="a2">第二張</button>
<button class="a3">第三張</button>
</body>
</html>
發佈了76 篇原創文章 · 獲贊 7 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章