gpt4 book ai didi

javascript - 随图像旋转图像标题

转载 作者:行者123 更新时间:2023-11-28 10:20:36 25 4
gpt4 key购买 nike

我有一个相册,其中有带分页的旋转图像。我想在图像下方显示标题,并且标题也应该随着图像的变化而变化。

我写了以下html代码

<div class="slider_box">
<div align="left" id="slider2" class="sliderwrapper">
#IMG#
</div>
<div id="paginate-slider2" class="pagination"></div>
</div>
<span class="slider_box">
<span align="left" id="slider" class="sliderwrapper">
#CAPTION#
</span>
</span>


<script>
featuredcontentslider.init({
id: "slider2",
//id of main slider DIV
contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
//toc: "<img src=images/dot_white.jpg align=absmiddle border=0>", //Valid values: "#increment", "markup", ["label1", "label2", etc]
toc: " &nbsp;&nbsp;",
nextprev: ["", ""], //labels for "prev" and "next" links. Set to "" to hide.
revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
enablefade: [true, 0.1], //[true/false, fadedegree]
autorotate: [true, 6000], //[true/false, pausetime]
onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
}
})

featuredcontentslider.init({
id: "slider",

//id of main slider DIV
contentsource: ["inline", ""], //Valid values: ["inline", ""] or ["ajax", "path_to_file"]

//toc: "<img src=images/dot_white.jpg align=absmiddle border=0>", //Valid values: "#increment", "markup", ["label1", "label2", etc]
toc: " &nbsp;&nbsp;",
nextprev: ["", ""], //labels for "prev" and "next" links. Set to "" to hide.
revealtype: "click", //Behavior of pagination links to reveal the slides: "click" or "mouseover"
enablefade: [true, 0.1], //[true/false, fadedegree]
autorotate: [true, 6000], //[true/false, pausetime]
onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
}
})</script>

这样做的问题是所有图像的标题一起显示在不旋转的图像下方..:(

最佳答案

如果没有看到你的其余代码,我会认为你有一个 slider 并且有这个

<span align="left" id="caption">

#CAPTION#

</span>

var captions["Caption for image1", "Caption for image2"]

并更改脚本的 onChange 部分

onChange: function(previndex, curindex){ 
//event handler fired whenever script changes slide
//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
document.getElementById("caption").innerHTML=captions[curindex];
}

关于javascript - 随图像旋转图像标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5739887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com