我已经下载了这段代码,它正在运行,但当我点击上一张和下一张图片的那段时间它无法正常工作时,我不知道会怎样做... $(“。pic img”)。attr( “src”,“images /这里我想要下一个图像src值”);
<div class="img-box">
<ul>
<?php $query1="SELECT * FROM user_photos_offline" ; $sql=mysql_query($query1); $results=array(); while($row=mysql_fetch_assoc($sql)){ ?>
<li>
<img src="images/cropped-images/<?php echo $row['image']?>" />
<div class="mask">
<div class="mag">
<div class="plus"></div>
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
<div class="full-screen-mask">
<div class="view-port">
<div class="pre">
<span>-</span>
</div>
<div class="pic"><img /></div>
<div class="next">
<span>+</span>
</div>
</div>
<div class="close">
<span></span>
<span></span>
</div>
</div>
$(".img-box ul li").click(function() {
var index = $(this).index();
num = index + 1;
var img = $(this).find('img').attr('src');
var index = $(this).index();
//next button function
function next() {
$(".pic img").attr("src", "images/"+num+".png");
}
$(".next").click(next);
});
//preview button function
function pre(){
$(".pic img").attr("src","images/pic-"+num+".png");
num--;
if(num==0){
num=8
}
}
$(".pre").click(pre);
//next button function
function next(){
$(".pic img").attr("src","images/pic-"+num+".png");
num++;
if(num==9){
num=1
}
}
$(".next").click(next);
答案 0 :(得分:0)
您的脚本不在标签中,
<script type="text/javascript"></script>
检查你的阻止。看起来你在click块中运行next()。 你在它之外设置了监听器。