- $(document).ready(function() {
- var z = 0;
- var inAnimation = false;
- $('#box img').each(function() {
- z++;
- $(this).CSS('z-index', z);
- });
- function slide() {
- if(inAnimation) return false;
- else inAnimation = true;
- var MaxZindex = z; SecondZindex = z-1;
- $('#box img').each(function() {
- if($(this).css('z-index') == MaxZindex) {
- $(this).animate({left:"350px"}, 800, function() {
- $(this).css('z-index', 1)
- .animate({left:"0px"}, 800, function() {
- inAnimation = false;
- });
- });
- } else if($(this).css('z-index') == SecondZindex) {
- $(this).animate({left:"-80px"}, 800, function() {
- $(this).css('z-index', parseInt($(this).css('z-index')) + 1);
- }).animate({left:"0px"}, 800);
- }else{
- $(this).animate({left:"0px"}, 600, function() {
- $(this).css('z-index', parseInt($(this).css('z-index')) + 1);
- });
- }
- });
- return false;
- }
- $('#box').click(function() {
- slide();
- });
- });
- //该片段来自于http://www.codesnippet.cn/detail/240620134224.html
来源: http://www.codesnippet.cn/detail/240620134224.html