$(document).ready(function(){ setinterval("scroll()",4000); }); var index = 0;//初始下标 function scroll(){ var pic_inner = $(".pics_div .carousel-inner"); var pic_inner_el = $(".pics_div .carousel-inner .item"); var word_inner = $(".word_div .carousel-inner"); var word_inner_el = $(".word_div .carousel-inner .item"); /* * 开始模拟动�? */ //先将要出现的元素的下�? var old_index = index; index += 1; if (index == pic_inner_el.length) { index = 0; } //将元素放置在右边 pic_inner_el.eq(index).stop(true, false).animate({ "left": "100%"}, 0 ,function(){ $(this).addclass('active next'); }); word_inner_el.eq(index).stop(true, false).animate({ "left": "100%","opacity": "1"}, 0 ,function(){ $(this).addclass('active next'); }); //向左滑动 pic_inner_el.eq(index).animate({ "left": "0" }, 600 ,function(){ // alert(1); $(this).removeclass('next'); }); word_inner_el.eq(index).animate({ "left": "0" }, 600 ,function(){ $(this).removeclass('next'); }); pic_inner_el.eq(old_index).animate({ "left": "-100%" }, 600 ,function(){ // alert(2); $(this).removeclass('active'); }); word_inner_el.eq(old_index).animate({ "opacity": "0" }, 600 ,function(){ $(this).removeclass('active'); }); } function supportcss3(style) { var prefix = ['webkit', 'moz', 'ms', 'o'], i, humpstring = [], htmlstyle = document.documentelement.style, _tohumb = function (string) { return string.replace(/-(\w)/g, function ($0, $1) { return $1.touppercase(); }); }; for (i in prefix) humpstring.push(_tohumb(prefix[i] + '-' + style)); humpstring.push(_tohumb(style)); for (i in humpstring) if (humpstring[i] in htmlstyle) return true; return false; }