我为照片导航器编写了一些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>")
});