【问题标题】:Slideshow links, sliding, buttons幻灯片链接、滑动、按钮
【发布时间】:2014-02-28 22:22:09
【问题描述】:

事情是http://jsfiddle.net/hTZWq/2/

     $(".image").wrap("<a href=\"link.html\"></a>");

我想将这些变量放在链接上,这样当图片更改时,每张图片都有链接。 有了这些代码,我的按钮就不能在我的电脑上工作了,但它们可以工作吗?!奇怪。

它不断地用这些间隔功能改变我的第一张照片。

有人可以帮忙吗!

【问题讨论】:

    标签: java javascript jquery html css


    【解决方案1】:

    像这样存储图像怎么样:

    var image = [
        {src: "pretend this is an image", link: "http://www.google.com"},
        {src: "and lets pretend this is another", link: "http://www.yahoo.com"},
        {src: "and one more for show", link: "http://www.stackoverflow.com"}
    ];
    

    然后您可以更改您的 html() 方法以在生成标记时传入 image.srcimage.link 属性。

    【讨论】:

    • 我是一个初学者,所以有点难以理解你在说什么:/,带有“然后你可以改变你的 html() 方法来传递 image.src 和 image.link 属性的部分生成标记时。”
    【解决方案2】:

    你可以试试这个代码:

    HTML

    <a href="link1.html" class="picture">pretend this is an image</a>
    <div class="bullet">click here to change manually</div>
    

    jQuery:

    $(document).ready(function () {
        setInterval(function () { //change this to setInterval to make it constantly flip through rather than one time
            change();
        }, 2400);
    });
    
    var image = [
        ["pretend this is an image", "link1.html"],
        ["and lets pretend this is another", "link2.html"],
        ["and one more for show", "link3.html"]
    ];
    var index = 1;
    
    $(".bullet").click(function () {
        change();
    });
    
    function change() {
        if (index == 3) {
            index = 0;
        }
        $(".picture").fadeOut(1000, function () {
            $(".picture").html(image[index][0]);
            $(".picture").attr("href", image[index][1]);
            $(".picture").fadeIn(1000);
            index++;
        });
    }
    

    检查您的updated Fiddle

    【讨论】:

    • 你自己尝试了什么?
    • 我发布了错误的代码,我使用的代码是这个jsfiddle.net/y8n3W,因为我是新手,所以我还不太了解“编码”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    相关资源
    最近更新 更多