Javascript 通过jQuery制作图像幻灯片和文本
我想在不使用插件的情况下,在下图中用show text(title tagJavascript 通过jQuery制作图像幻灯片和文本,javascript,jquery,slideshow,Javascript,Jquery,Slideshow,我想在不使用插件的情况下,在下图中用show text(title tag中的每一个文本)制作一个jquery幻灯片,我尝试如下:(它不起作用[我应该使用classdiv.mediumCell来显示tagimg中的每一个文本,并用文本显示它]) 演示: $('.fadein.mediumCell:not(:first)).hide(); 设置间隔(showNext,3000); 函数showNext(){ $('div#caption')。删除(); 当前变量=$('.fadein:first
中的每一个文本)制作一个jquery幻灯片,我尝试如下:(它不起作用[我应该使用classdiv.mediumCell
来显示tagimg
中的每一个文本,并用文本显示它])
演示:
$('.fadein.mediumCell:not(:first)).hide();
设置间隔(showNext,3000);
函数showNext(){
$('div#caption')。删除();
当前变量=$('.fadein:first child');
var next=当前的.next('.mediumCell');
电流衰减(“慢”,功能(){
$(this.appendTo('.fadein');
})
标题(下一页);
$(next).next(“.mediumCell”).andSelf().fadeIn()
};
函数标题(元素){
$('').hide().html($(元素).attr(“alt”).insertAfter($(元素)).fadeIn();
};
如何修复它?对于您来说,html是:
<div class="presentaion">
<span class="caption"></span>
<img src="http://www.ct4me.net/images/Showing_Grade_1.jpg" width="100px" title="MyTitle_1" />
<img src="http://www.ct4me.net/images/dmbtest.gif" width="100px" title="MyTitle_2" />
<img src="http://celticevolution.com/images/test-201.gif" width="100px" title="MyTitle_3" />
</div>
已编辑但您更改了我的代码)请尝试不更改代码,并将html重新格式化为所需的格式。
//在编辑所有
之前,需要在其中包含div.presentation和span标题。现在它可以工作了,setTimeout()
中出现错误,很抱歉。如果可能的话,请给出任何反馈,以了解它是否适合您。
<div class="presentaion">
<span class="caption"></span>
<img src="http://www.ct4me.net/images/Showing_Grade_1.jpg" width="100px" title="MyTitle_1" />
<img src="http://www.ct4me.net/images/dmbtest.gif" width="100px" title="MyTitle_2" />
<img src="http://celticevolution.com/images/test-201.gif" width="100px" title="MyTitle_3" />
</div>
show($('div.presentaion img:first')); // show first slide
function show(el) {
el.parents('div.presentaion').find('img').hide(); // hide all slide
el.prev('span.caption:first').html(el.attr('title')); // show caption from title
el.show(); // show image
setTimeout(function() {
if (typeof(el.next('img:first')) != 'undefined') {
show(el.next('img:first')); // set timeout to show next
}
}, 3000);
}