所以,我有一个网站,它有一个随机加载幻灯片,其中 div 容器为每张幻灯片调用文本。我希望能够为特定单词添加链接和/或颜色更改。这是我到目前为止所拥有的 JSFIDDLE 链接:http: //jsfiddle.net/shadna/Agq7W/
为方便起见,这里是编码:
JS::
jQuery(function($){
$('#homebanner').css({backgroundColor: "#000"});
var totalCount = 4;
var num = Math.ceil( Math.random() * totalCount );
var hText = ["WE SPEAK ARCHITECTURE", "WE HAVE HIGH SPIRIT(S)", "STRATEGY: BUILT ON HUMAN-CENTERED", "FOREVER IN BLUE JEANS"];
var hsubText = ["CLIENT: EDA ARCHITECTS", "CLIENT: HIGH WEST DISTILLERY", "CLIENT: ARCHITECTURAL NEXUS", "CLIENT: VAULT DENIM"];
function setBGImage() {
var bgimage = 'http://bwpcommunications.com/TESTING/images/homepage/'+num+'.jpg';
$('#homebanner').css({
backgroundImage:"url("+bgimage+")",
});
$('#htxt').html(hText[num - 1]);
$('#hsubtxt').html(hsubText[num - 1]);
}
setBGImage();
});
HTML::
<div id="homebanner">
<div id="hwrap">
<div id="htxt"></div>
<div id="hsubtxt"></div>
</div>
</div>
任何信息都会对这个卑微的 JS 学习者有所帮助。