Here is a code snippet that generates random background images for a div
. I am looking to add description divs for each background image.
<div class="slider"></div>
$(function () {
var url = "http://maispc.com/samuel/content/images/",
imgArray = [url+"avatar.png",
url+"provider/blogger.png",
url+"provider/LinkedIn-32x32.png",
url+"provider/myspace.png",
url+"provider/instagram.png",
url+"provider/Twitter-32x32.png",
url+"provider/stackoverflow.png",
url+"provider/Facebook-32x32.png"],
randomNumber = Math.floor((Math.random() * imgArray.length)),
baseUrl = "url('" + imgArray[randomNumber] + "')";
$(".slider", ".tab").css('background-image', baseUrl);
})();
I want the code to look like this:
{ $(function () {
var url = "http://maispc.com/samuel/content/images/",
imgArray = [url+"avatar.png",
url+"provider/blogger.png", // description div 1
url+"provider/LinkedIn-32x32.png", // description div 2
url+"provider/myspace.png", // and so on...
url+"provider/instagram.png",
url+"provider/Twitter-32x32.png",
url+"provider/stackoverflow.png",
url+"provider/Facebook-32x32.png"],
randomNumber = Math.floor((Math.random() * imgArray.length)),
baseUrl = "url('" + imgArray[randomNumber] + "')";
$(".slider").css('background-image', baseUrl);
})();
}