jQuery照片导航器功能-下一个和上一个按钮

jQuery照片导航器功能-下一个和上一个按钮,jquery,photo-gallery,navigationcontroller,Jquery,Photo Gallery,Navigationcontroller,我已经为照片导航器编写了一些jQuery,但是当我按下“后退”按钮时,它就不起作用了。但是,当我首先单击“下一步”按钮时,“后退”按钮确实起作用。更糟糕的是,当我首先单击“后退”按钮时,“下一步”按钮停止工作。有什么想法吗 以下是两个按钮的代码: /* === Previous Button === */ $("#photo_show a#back").click(function(event) { var placeHolder2 = curPhoto; event.pre

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

以下是两个按钮的代码:

/* === 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>")
});
/*==上一个按钮===*/
$(“照片”显示背面)。单击(功能(事件){
var占位符2=curPhoto;
event.preventDefault();
nextPhoto=curPhoto;
curPhoto=placeholder 2.prev();
如果(curPhoto.length==0){
curPhoto=$(#画廊a:最后一张”);
}
$(“显示照片”).html(“”);
$(“p#caption”).html(

“+curPhoto.attr(“title”)+“

”) }); /*==下一步按钮===*/ $(“#照片#显示#下一步”)。单击(功能(事件){ var占位符=下一张照片; event.preventDefault(); curPhoto=nextPhoto; nextPhoto=占位符.next(); if(nextPhoto.length==0){ 下一张照片=$(#画廊a:第一张”); } $(“显示照片”).html(“”); $(“p#caption”).html(

“+curPhoto.attr(“title”)+“

”) });
我看到您正在

的内部创建

,这可能不是您想要的。请同时添加HTML代码。似乎还缺少一些JS,什么类型是
curPhoto