首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquerytools在scrollable上切换播放/暂停按钮

jquerytools在scrollable上切换播放/暂停按钮
EN

Stack Overflow用户
提问于 2013-04-30 12:28:54
回答 1查看 562关注 0票数 0

您好,我使用这个http://jquerytools.org/demos/scrollable/gallery.html在Jquerytools上构建了一个幻灯片。

和自动滚动http://jquerytools.org/documentation/scrollable/autoscroll.html

http://jsfiddle.net/PcAwU/

我的问题是我可以合并播放和暂停按钮,这样如果播放是活动的,就会显示暂停,反之亦然。

http://jsfiddle.net/PcAwU/在这里你可以找到我的代码..

另外,如果您能告诉我如何更改

代码语言:javascript
复制
<button type="button" onClick="api.play()">Play</button>

点击正常的img链接,这样我就可以制作像这样的图像按钮

代码语言:javascript
复制
<a href="#"  onClick="api.play()" ><img src="#"></a>

只要使用正确的语法,

最后一个问题是,在这一部分中,我尝试用hover替换de click。但是加载页面时不会显示第一张图片。所以当我这样做的时候,我创建了一个“故障”

这一行是我将"click“改为"hover”的地方。

代码语言:javascript
复制
$(".items img").click(function() {
EN

回答 1

Stack Overflow用户

发布于 2013-05-01 04:16:11

使用

代码语言:javascript
复制
<script>
$(function() {
var root = $(".scrollable").scrollable({circular: false}).autoscroll({ autoplay: true });

$(".items img").click(function() {
    // see if same thumb is being clicked
    if ($(this).hasClass("active")) { return; }

    // calclulate large image's URL based on the thumbnail URL (flickr specific)
    var url = $(this).attr("src").replace("_t", "");

    // get handle to element that wraps the image and make it semi-transparent
    var wrap = $("#image_wrap").fadeTo("medium", 0.5);

    // the large image from www.flickr.com
    var img = new Image();


    // call this function after it's loaded
    img.onload = function() {

        // make wrapper fully visible
        wrap.fadeTo("fast", 1);

        // change the image
        wrap.find("img").attr("src", url);

    };

    // begin loading the image from www.flickr.com
    img.src = url;

    // activate item
    $(".items img").removeClass("active");
    $(this).addClass("active");

// when page loads simulate a "click" on the first image
}).filter(":first").click();

// provide scrollable API for the action buttons
window.api = root.data("scrollable");

});


function toggle(el){
    if(el.className!="play")
    {
        el.className="play";
         el.src='images/play.png';
        api.pause();
    }
    else if(el.className=="play")
    {
        el.className="pause";
         el.src='images/pause.png';
        api.play();
    }

    return false;
}

</script>

按钮是这样的:

代码语言:javascript
复制
<input type="image" src="images/atras.png" onclick="api.prev()" >

   <input type="image" src="images/pause.png" class="pause" onclick="toggle(this);" >

   <input type="image" src="images/adelante.png" onclick="api.next()" >

我希望这对某些人有帮助

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16292174

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档