0

我已经为照片导航器编写了一些 jQuery,但是当我按下“返回”按钮时它不起作用。但是,当我首先单击“下一步”按钮时,后退按钮确实有效。更糟糕的是,当我首先单击“返回”按钮时,“下一步”按钮停止工作。有任何想法吗?

这是 2 个按钮的代码:

/* === Previous Button === */

$("#photo_show a#back").click(function(event) {

    var placeHolder2 = curPhoto;
    event.preventDefault();
    nextPhoto = curPhoto;
    curPhoto = placeHolder2.prev(); 
    if(curPhoto.length == 0){
            curPhoto = $("#gallery a:last");
    }
    $("span#display_photo").html("<img id=\"display_photo\" src=\"" + curPhoto.attr("href") + "\" width=\"500\" height=\"350\"/>");
    $("p#caption").html("<p id=\"caption\"><em>" + curPhoto.attr("title") + "</em></p>")    
});

/* === Next Button === */

$("#photo_show a#next").click(function(event) {

    var placeHolder = nextPhoto;
    event.preventDefault();
    curPhoto = nextPhoto;
    nextPhoto = placeHolder.next();
    if(nextPhoto.length == 0){
        nextPhoto = $("#gallery a:first");
    }

    $("span#display_photo").html("<img id=\"display_photo\" src=\"" + curPhoto.attr("href") + "\" width=\"500\" height=\"350\"/>");
    $("p#caption").html("<p id=\"caption\"><em>" + curPhoto.attr("title") + "</em></p>")
});
4

0 回答 0