yangl_china 2017-10-12 06:39 采纳率: 0%
浏览 1129

自己写的轮播图,为什么点上一页的按钮就能点一下,还不报错。求大神简答

// JavaScript Document
$(document).ready(function() {

//执行幻灯片
slideShow();

});

function slideShow() {

//将所有图像的value设置为0
$('#gallery a').val("0");

//获取第一个图像并显示它
$('#gallery a:first').val("1");

//设置标题背景半透明
$('#gallery .caption').css({opacity: 0.0});

//调整文字宽度根据图像宽度
$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});

//从rel属性获得第一个图像字幕显示
$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'));
$('#gallery .caption').animate({height: '500px',opacity: 0.0},100).animate({height: '500px',opacity: 0.7},1000);
$('#gallery .caption .tit img').animate({left: '-900px'},100).animate({left: '0px'},1000);

//运行幻灯片,6秒
//timer=setInterval('gallery()',4000);
//首页点击
$('#first_page').click(function(){
    gallery();  
});

}

function gallery() {
$('#gallery .content').html("");
//判断第一张图片
var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first'));

//获取下一个图像,如果它达到的幻灯片结束,旋转它回到第一图像
var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));

//获取下一个图像标题
var caption = next.find('img').attr('rel');

//设置下一个图像的淡入效果
next.addClass('show')
.animate({value: 1}, 1000);

//隐藏当前图像
current.animate({value: 0}, 1000)
.removeClass('show');

//加入动画
animation()

//显示的内容
$('#gallery .content').html(caption);

//点击右键
$('.right').click(function(){
    //clearInterval(timer);
    gallery();
    //timer=setInterval('gallery()',4000);
});

//点击左键
$('.left').click(function(){
    $('#gallery .content').html("");
    //clearInterval(timer);
    //判断当前图片
    var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:lest'));

    //获取上一个图像,如果它达到的幻灯片第一个,旋转它回到最后一个
    var prev = ((current.prev().length) ? ((current.prev().hasClass('caption'))? $('#gallery a:lest') :current.prev()) : $('#gallery a:lest')); 

    //获取上一个图像标题
    var caption = prev.find('img').attr('rel');

    //设置上一个图像的淡入效果
    prev.addClass('show')
    .animate({value: 1}, 1000);

    //隐藏当前图像
    current.animate({value: 0}, 1000)
    .removeClass('show');

    //加入动画
    animation()

    //显示的内容
    $('#gallery .content').html(caption);
    //timer=setInterval('gallery()',4000);
});

//末页点击
$('#last_page').click(function(){
    window.location.reload();   
});

}

function animation(){

if($('a:nth-child(1)').val()==1||$('a:nth-child(5)').val()==1||$('a:nth-child(9)').val()==1||$('a:nth-child(13)').val()==1){

    $('#gallery .caption')
    .animate({height: '500px',opacity: 0.0},100)
    .animate({height: '500px',opacity: 0.7},1000);

}else{

    $('#gallery .caption')
    .animate({height: '75px',opacity: 0.0},100 )
    .animate({height: '75px',opacity: 0.7},1000);

}   

}

  • 写回答

1条回答 默认 最新

  • 铛铛铛铛Huan 2017-10-13 07:13
    关注

    HTML页面的代码能否也贴上?我可以调调看

    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样