JQuery next() 问题
我正在尝试使用 next() 和 end() 简化此图像旋转器函数,但我无法弄清楚。目标是迭代图像、设置标题并移至下一个图像。 我怎样才能做到这一点?
这是我的基本 html 代码
<div class="object">
<div class="stories">
<div class="story" title="Microsoft Expression Encoder"
<img src="http://example.com/sample.png" title="" alt=""/>
</div>
<div class="story" title="Microsoft Expression Encoder Repeat" >
<img src="http://example.com/sample.png" title="" alt=""/>
</div>
</div>
<div class="titlebar">
<div class="info"></div>
<div id="btn_next" class="btn_next"></div>
<div id="btn_prev" class="btn_prev"></div>
</div>
</div>
这是 JavaScript 代码
var rotateImages = function () {
$('.stories div:gt(0)').hide();
$(".info").text($(".story").attr("title"));
$(".stories div:eq(0)")
.animate({ options}, 250,function () {
$(".jqb_info").text($(this).attr(title)).animate({ options }, 500);)
.next('div')animate ({options}, 250, function () {
$(".jqb_info").text($(this).attr(title)).animate({ options }, 500);)
.end().appendTo('.stories');
}
I am trying simplify this images rotator function using the next() and end() but I can't figure it out. The goal is to iterate over images, set the title and move to the next image.
How can I make this work?
here is my basic html code
<div class="object">
<div class="stories">
<div class="story" title="Microsoft Expression Encoder"
<img src="http://example.com/sample.png" title="" alt=""/>
</div>
<div class="story" title="Microsoft Expression Encoder Repeat" >
<img src="http://example.com/sample.png" title="" alt=""/>
</div>
</div>
<div class="titlebar">
<div class="info"></div>
<div id="btn_next" class="btn_next"></div>
<div id="btn_prev" class="btn_prev"></div>
</div>
</div>
here is the JavaScript code
var rotateImages = function () {
$('.stories div:gt(0)').hide();
$(".info").text($(".story").attr("title"));
$(".stories div:eq(0)")
.animate({ options}, 250,function () {
$(".jqb_info").text($(this).attr(title)).animate({ options }, 500);)
.next('div')animate ({options}, 250, function () {
$(".jqb_info").text($(this).attr(title)).animate({ options }, 500);)
.end().appendTo('.stories');
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会在 .text 函数中出现这些分号的错误。
You may be getting an error having those semicolons inside your .text functions.