幻灯片链接,滑动,按钮

时间:2014-02-28 14:12:09

标签: java javascript jquery html css

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

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

我想把这些var放在链接上,所以当pic改变时,它有每个图片的链接。 使用这些代码我的按钮不能在我的计算机上工作,它们在小提琴中工作吗?奇怪。

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

有人可以帮忙!

2 个答案:

答案 0 :(得分:0)

如何存储这样的图像:

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属性。

答案 1 :(得分:0)

您可以尝试以下代码:

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