JQuery next() 问题

发布于 2024-10-03 00:11:36 字数 1294 浏览 0 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夕色琉璃 2024-10-10 00:11:36

您可能会在 .text 函数中出现这些分号的错误。

You may be getting an error having those semicolons inside your .text functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文