2017-04-13 8 views
0

アレイの残りのイメージを1つずつ切り替えてイメージのリストを切り替えようとしています。私は15枚の画像を並べて表示していますが、残りの画像を1枚ずつ切り替える必要があります。アレイのフェードイン/アウト画像

var images = [ 
 
'<img class="wp-image-2443" src="http://2-story.com/wp-content/uploads/2012/07/ab-data.png" alt="ab Data" />', 
 
'<img class="wp-image-2444" src="http://2-story.com/wp-content/uploads/2012/07/american-transmission-company.png" alt="American Transmission Company" />', 
 
'<img class="wp-image-2445" src="http://2-story.com/wp-content/uploads/2012/07/arts-at-large.png" alt="Arts @ Large" />', 
 
'<img class="wp-image-2446" src="http://2-story.com/wp-content/uploads/2012/07/baseball-tomorrow.png" alt="Baseball Tomorrow" />', 
 
'<img class="wp-image-2447" src="http://2-story.com/wp-content/uploads/2012/07/brewers-community-foundation.png" alt="Brewers Community Foundation" />', 
 
'<img class="wp-image-2448" src="http://2-story.com/wp-content/uploads/2012/07/city-of-milwaukee.png" alt="City of Milwaukee" />', 
 
'<img class="wp-image-2449" src="http://2-story.com/wp-content/uploads/2012/07/columbia-stmarys-foundation.png" alt="Columbia St. Mary Foundation" />', 
 
'<img class="wp-image-2450" src="http://2-story.com/wp-content/uploads/2012/07/digestive-health-insurance.png" alt="Digestive Health Alliance" />', 
 
'<img class="wp-image-2451" src="http://2-story.com/wp-content/uploads/2012/07/dorner.png" alt="Dorner" />', 
 
'<img class="wp-image-2486" src="http://2-story.com/wp-content/uploads/2012/07/echelon-innovation-campus.png" alt="Echelon Innovation Campus" />', 
 
'<img class="wp-image-2452" src="http://2-story.com/wp-content/uploads/2012/07/great-lakes-distillery.png" alt="Great Lakes Distillery" />', 
 
'<img class="wp-image-2453" src="http://2-story.com/wp-content/uploads/2012/07/habitati-for-humanity.png" alt="Habitat for Humanity" />', 
 
]; 
 
$(document).ready(function(){ 
 
    
 
    $.each(images, function(index, image) { 
 
    if (index > 5) { 
 
      return false; 
 
     } 
 
    
 
     $('.logo-container').append(image); 
 
    
 
    }); 
 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div class="logo-container"> 
 

 
</div>
enter image description here

+0

_あなたが何を意味するか_定かではない「私は、私はそれらの6表示15枚の画像の配列を持っている、と私は、画像を1枚ずつを切り替える必要がありますか」?最初の6つは表示されたままで、7番目の画像は残りの9つの画像に循環されますか? – guest271314

答えて

0

これは、あなたのイメージにしたいとまったく効果はありませんが、これは、あなたがそれに変更を加えることができますachieve.Youしようとしているものを行います。

$(document).ready(function(){ 
 
var images = [ 
 
'<img class="wp-image-2443" src="http://2-story.com/wp-content/uploads/2012/07/ab-data.png" alt="ab Data" />', 
 
'<img class="wp-image-2444" src="http://2-story.com/wp-content/uploads/2012/07/american-transmission-company.png" alt="American Transmission Company" />', 
 
'<img class="wp-image-2445" src="http://2-story.com/wp-content/uploads/2012/07/arts-at-large.png" alt="Arts @ Large" />', 
 
'<img class="wp-image-2446" src="http://2-story.com/wp-content/uploads/2012/07/baseball-tomorrow.png" alt="Baseball Tomorrow" />', 
 
'<img class="wp-image-2447" src="http://2-story.com/wp-content/uploads/2012/07/brewers-community-foundation.png" alt="Brewers Community Foundation" />', 
 
'<img class="wp-image-2448" src="http://2-story.com/wp-content/uploads/2012/07/city-of-milwaukee.png" alt="City of Milwaukee" />', 
 
'<img class="wp-image-2449" src="http://2-story.com/wp-content/uploads/2012/07/columbia-stmarys-foundation.png" alt="Columbia St. Mary Foundation" />', 
 
'<img class="wp-image-2450" src="http://2-story.com/wp-content/uploads/2012/07/digestive-health-insurance.png" alt="Digestive Health Alliance" />', 
 
'<img class="wp-image-2451" src="http://2-story.com/wp-content/uploads/2012/07/dorner.png" alt="Dorner" />', 
 
'<img class="wp-image-2486" src="http://2-story.com/wp-content/uploads/2012/07/echelon-innovation-campus.png" alt="Echelon Innovation Campus" />', 
 
'<img class="wp-image-2452" src="http://2-story.com/wp-content/uploads/2012/07/great-lakes-distillery.png" alt="Great Lakes Distillery" />', 
 
'<img class="wp-image-2453" src="http://2-story.com/wp-content/uploads/2012/07/habitati-for-humanity.png" alt="Habitat for Humanity" />', 
 
]; 
 
var startingIndex = 0; 
 
var endIndex = 5; 
 
displayImages(images.slice(startingIndex, endIndex)); \t 
 
setInterval(function(){ 
 
\t if(endIndex >= images.length) endIndex = images.length/2; 
 
\t updateImages(images[endIndex]); 
 
\t endIndex++; 
 
}, 3000); 
 

 
function displayImages(imageArray){ 
 
    $.each(imageArray, function(index, image) {  
 
     $('.logo-container').append(image); 
 
    }); \t 
 
} 
 
function updateImages(image){ 
 
\t $('.logo-container img').first().fadeOut("slow", function(){ 
 
\t \t $(this).replaceWith(image); 
 
\t \t $(this).fadeIn("slow"); 
 
\t }); 
 
} \t 
 

 
});
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width"> 
 
    <title>JS Bin</title> 
 
</head> 
 
<body> 
 
<div class="logo-container"> 
 

 
</div> \t 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
</body> 
 
</html>

関連する問題