Replacing img tags in jQuery slideshow with JavaScript alternative
I have a slideshow script written in jQuery which currently pulls the URLs for my images from img tags in my HTML code. You can find my working code here http://jsfiddle.net/F4uhJ/.
I want my code to get the URL from a JavaScript instead of the img tags. For example:
0:"image-url",
1:"image-url",
2:"image-url",
3:开发者_开发百科"image-url",
4:"image-url",
How could I impliment this into my current code? Again, the link is http://jsfiddle.net/F4uhJ/.
Something like this http://jsfiddle.net/niklasvh/F4uhJ/13/ ?
Edited bits:
var imgarray = ['http://img.wallpaperstock.net:81/king-john%27s-castle-wallpapers_4579_1600x1200.jpg',
'http://news.satimagingcorp.com/wp-content/uploads/2007/07/colosseum_in_rome_italy_-_april_2007.jpg'
];
$.each(imgarray,function(index,item){
var child = $('<img />').attr('src',item).appendTo(slider);
var childHeight = child.height();
if(childHeight > slider.height()){
slider.height(childHeight);
}
child.css('display','none');
});
var kids = slider.children();
精彩评论