html部分
css部分
1 * {js部分
1 $(function(){ 2 //鼠标移入显示箭头按钮 3 $('.cm-banner').hover(function(){ 4 $('.cm-banner-arrow').show(); 5 clearInterval(cm_timer); 6 },function(){ 7 $('.cm-banner-arrow').hide(); 8 cm_timer = setInterval(function(){ 9 i++;10 if(i > cm_length - 1){11 i = 0;12 }13 $('#cm_banner_list li').eq(i).fadeIn(800).siblings().fadeOut(800);14 cm_toggle(i);15 },2500);16 });17 18 //鼠标移入箭头按钮高亮19 $('.cm-banner-arrow').hover(function(){20 $(this).css('opacity','1');21 },function(){22 $(this).css('opacity','0.5');23 });24 25 //初始化必要变量26 var i = 0;27 var cm_length = $('#cm_banner_list li').length;28 var cm_toggle = function(point){29 $('#cm_banner_num li').eq(point).addClass('active').siblings().removeClass('active');30 };31 32 //动态添加小圆点33 for(j = 0;j < cm_length;j++){34 $('#cm_banner_num').append('<li></li>');35 }36 37 //给第一个小圆点添加样式38 $('#cm_banner_num li').first().addClass('active');39 40 //给第一张图片添加样式41 $('#cm_banner_list li').first().css('display','block');42 43 //鼠标点击左箭头切换44 $('#cm_prev').click(function(){45 i--;46 if(i < 0){47 i = cm_length - 1;48 }49 $('#cm_banner_list li').eq(i).fadeIn(800).siblings().fadeOut(800);50 cm_toggle(i);51 });52 53 //鼠标点击右箭头切换54 $('#cm_next').click(function(){55 i++;56 if(i > cm_length - 1){57 i = 0;58 }59 $('#cm_banner_list li').eq(i).fadeIn(800).siblings().fadeOut(800);60 cm_toggle(i);61 });62 63 //鼠标点击圆点切换64 $('#cm_banner_num li').click(function(){65 var cm_index = $(this).index();66 $('#cm_banner_list li').eq(cm_index).fadeIn(800).siblings().fadeOut(800);67 i = cm_index;68 cm_toggle(cm_index);69 });70 71 //自动播放72 cm_timer = setInterval(function(){73 i++;74 if(i > cm_length - 1){75 i = 0;76 }77 $('#cm_banner_list li').eq(i).fadeIn(800).siblings().fadeOut(800);78 cm_toggle(i);79 },2500);80 });
The above is the detailed content of jQuery implements carousel chart (width full screen and height fixed). For more information, please follow other related articles on the PHP Chinese website!