简体   繁体   English

pageAnchorBuilder问题-循环插件-JQuery:更改图像按钮

[英]pageAnchorBuilder question - Cycle Plugin - JQuery: Changing Image Buttons

I am using the Cycle plugin for JQuery to create a banner rotator with the pauseOnHover functionality. 我正在为JQuery使用Cycle插件来创建带有pauseOnHover功能的横幅旋转器。 I have it working properly and even have the pageAnchorBuilder working correctly so that it displays an image vs '1,2,3, etc. The problem is it can't find the images because I am not using images as the selector but divs. 我可以正常工作,甚至可以使pageAnchorBuilder正常工作,以便它显示图像vs'1、2、3等。问题是它找不到图像,因为我没有将图像用作选择器,而是使用了divs。

How can I change the following code to let me specify which unique image to display for each slide (div)? 如何更改以下代码以指定每张幻灯片(div)显示哪个唯一图像? When I place the image url (../images/tab.png) in the img src tag it displays a broken link. 当我将图片网址(../images/tab.png)放在img src标签中时,它显示了一个损坏的链接。 Even if that was to work it would not accomplish what I am trying to do, display a unique image per div. 即使这行得通,也无法完成我要尝试的工作,但每格显示一个唯一的图像。

I am trying to create a javascript version of something like this: http://www.bazaarvoice.com 我正在尝试创建类似这样的javascript版本: http : //www.bazaarvoice.com

Here is my code: 这是我的代码:

banner.js banner.js

$(document).ready(function() {
    $('.slideshow').cycle({
        speed:      200,
        timeout:    15000, 
        pager:      '#tabs',
        pagerEvent: 'mouseover',
        pauseOnPagerHover: true,
        pagerAnchorBuilder: function(i, slide){// callback fn for building anchor links:  function(index, DOMelement) 
    return '<a href="path-to-link"><img src="' + slide.src + '" height="47" width="189" /></a>';
}


    });
});

I think you have the wrong idea of what the pagerAnchorBuilder function actually is. 我认为您对pagerAnchorBuilder函数的实际含义有pagerAnchorBuilder You should already have the elements in the DOM and be returning the JQUERY SELECTOR for those elements, which corresponds to each of the slides (usually by the index passed to the function). 您应该已经在DOM中包含了元素,并且正在为这些元素返回JQUERY SELECTOR ,该元素对应于每个幻灯片(通常是通过传递给函数的索引)。 View one of the demos here . 此处查看演示之一。 It may help you get a better understanding of what's going on there. 它可以帮助您更好地了解那里发生的事情。

If you're trying to build a cycle that scrolls through anchors, you have to do nothing more than include your anchor HTML markup inside the (presumably) div.slidehow : 如果您要构建一个循环滚动锚点的循环, div.slidehow包括锚点HTML标记就可以了:

<div class="slideshow">
   <a href="path-to-link1"><img src="/images/src1.png" height="47" width="189" /></a>
   <a href="path-to-link2"><img src="/images/src2.png" height="47" width="189" /></a>
</div>

and the Cycle Plugin will do it for you. 循环插件将为您完成。 There are some limitations to using images inside anchors with this plugin, though. 但是,在此插件的锚点内使用图像有一些限制

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM