【发布时间】:2018-06-05 19:06:47
【问题描述】:
我正在尝试修复一些代码,这些代码旨在使用 JavaScript 为滑块中的图像生成数据交换值,但除非我有一个 src 标记,否则我无法让它工作,即使那样,唯一的图像显示的是我在 src 标记中引用的任何内容。
我觉得这应该可以工作,因为它似乎与 Foundation 文档中的数据交换设置相匹配,而且我没有在控制台中看到任何表明存在问题的错误。
代码如下:
var animallink = $('<a></a>').attr('href', animals[randomkeys[a]].link);
console.dir(animallistitem);
$('<img />').attr({
'data-interchange': '[' + uploaddirectory + animals[randomkeys[a]].images.med + ', small], [' + uploaddirectory + animals[randomkeys[a]].images.med + ', medium], [' + uploaddirectory + animals[randomkeys[a]].images.lg + ', large]',
'class':'orbit-image',
'alt': animals[randomkeys[a]].images.alttext
}).appendTo(animallink);
var animalcontainer = $('<div></div>').addClass('related__item-content');
$('<h2>' + dyktext + '</h2>').appendTo(animalcontainer);
$('<h3></h3>').addClass('related__name').text(nametext + animals[randomkeys[a]].animal).appendTo(animalcontainer);
if(animals[randomkeys[a]].location != ""){
$('<h3></h3>').addClass('related__location').text(locationtext + animals[randomkeys[a]].location).appendTo(animalcontainer);
}
var rndnum = Math.round(Math.random() * (animals[randomkeys[a]].animalfacts.length - 1));
$('<p></p>').addClass('related__description').html(animals[randomkeys[a]].animalfacts[rndnum].replace('\u0026', '&')).appendTo(animalcontainer);
$('<div></div>').addClass('related__cta').html(morelinktext + ' <i class="fa fa-arrow-circle-right" aria-hidden="true"></i>').appendTo(animalcontainer);
animalcontainer.appendTo(animallink);
animallink.appendTo(animallistitem);
animallistitem.appendTo(animallist);
});
var orbit = new Foundation.Orbit($('.related__animal-facts .orbit'));
【问题讨论】:
标签: javascript zurb-foundation zurb-foundation-6