从HTML动态地为幻灯片提供图像(jQuery映射/get)

从HTML动态地为幻灯片提供图像(jQuery映射/get),jquery,image,map,slideshow,jquery-backstretch,Jquery,Image,Map,Slideshow,Jquery Backstretch,我正在使用很棒的插件来制作我的背景幻灯片。这是向其传递图像的常用方法 $.backstretch([ "http://dl.dropbox.com/u/515046/www/outside.jpg", "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg", "http://dl.dropbox.com/u/515046/www/cheers.jpg" ], {duration: 3000, fade: 7

我正在使用很棒的插件来制作我的背景幻灯片。这是向其传递图像的常用方法

$.backstretch([
    "http://dl.dropbox.com/u/515046/www/outside.jpg", 
    "http://dl.dropbox.com/u/515046/www/garfield-interior.jpg", 
    "http://dl.dropbox.com/u/515046/www/cheers.jpg"
], {duration: 3000, fade: 750});
不过,我不想通过硬编码为它提供图像,我希望函数能够获取PHP在容器中生成的内容。这是我到目前为止所拥有的

var images = $('#background img').map(function() { return this.src; }).get();
$.backstretch([$images], {duration: 3000, fade: 750});
显然,这是行不通的——根据FireBug,变量图像没有定义(?)。虽然如果我“警告”该变量,它会显示以逗号分隔的图像URL


知道我做错了什么吗?谢谢大家!

这就足够了
backstretch
希望第一个参数是一个字符串数组,这些字符串是对图像的引用

$(document).ready(function () {
    var images = [];

    // iterate over your selection
    $('#background img').each(function () {
        // save source to list
        images.push(this.src);
    });

    // use plugin
    $.backstretch(images, {duration: 3000, fade: 750});
});
我还假设你的HTML是这样的

<div id="background">
    <img src="http://dl.dropbox.com/u/515046/www/outside.jpg" />
    <img src="http://dl.dropbox.com/u/515046/www/garfield-interior.jpg" />
</div>


php看起来像什么?您想从
图像列表中使用
backstretch
,对吗?假设这是
#背景img
选择器。