請告訴我爲什麼元素不會被刪除並且不會輪流顯示?jQuery點擊顯示元素
<!DOCTYPE html>
<html>
<head>
<link href="styles/my_style.css" rel="stylesheet">
</head>
<body>
<div class="main">
<img id="left_btn" src="images/left_btn.png" allt="left" />
<img id="right_btn" src="images/right_btn.png" allt="right" />
<div class="pic_box">
<div class="gall_one">
<h2>Lorem Ipsum1</h2>
<img src="images/mlp1.png" allt="mlp" />
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
</div>
<div class="gall_one2">
<h2>Lorem Ipsum2</h2>
<img src="images/mlp2.png" allt="mlp" />
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
</div>
<div class="gall_one3">
<h2>Lorem Ipsum3</h2>
<img src="images/mlp3.jpg" allt="mlp" />
<p>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
</div>
</div>
</div>
<script src="scripts/jquery-1.6.2.min.js"></script>
<script src="scripts/my_scripts.js"></script>
</body>
</html>
腳本:
c$(document).ready(function(){
$(".pic_box > div").hide();
$(".pic_box > div:first").show();
$("#right_btn").click(function(){
for(var img1=0; img1<3; img1++){
gall();
}
function gall(){
$(".pic_box > div").show().prev("div").remove();
}
});
我想,當你點擊#right_btn
取出一個DIV並顯示以下做。
這是什麼屬性'allt'? – melancia 2014-09-11 12:41:24
當你調試這個,特別是在哪裏失敗? JavaScript控制檯中是否有錯誤?點擊處理程序是否被調用?當你瀏覽代碼時,你的選擇器是否會找到你期望他們找到的元素?請明確點。 – David 2014-09-11 12:41:41
你有一個for循環,它將馬上刪除所有它們...... – epascarello 2014-09-11 12:43:06