当浏览器网址中存在#X时,此部分应触发点击图片...但它永远不会发生......
//
var hash = window.location.hash.slice(1);
if (hash) {
$("#barely_slide img[data-imgnum='"+ hash +"']").trigger("click");
} else {
move_slide();
}
需要触发的Actuall部分:
//
$("#barely_slide article img").on("click", function(){
if ($(this).attr("class") == "focus") {return false;}
//
$("#barely_slide article img").removeClass("previous");
$("#barely_slide article .focus").addClass("previous");
var image = $(this);
$(".previous").animate({"height":300,"margin-top":0}, "fast");
$("#barely_slide article .focus").removeClass("focus");
image.addClass("focus");
//
window.location.hash = image.attr("data-imgnum");
//
move_slide();
return false;
});
答案 0 :(得分:3)
请记住在触发它之前附上click
处理程序 :
$("#barely_slide article img").on("click", function() { // attach click handler
...
});
触发它(必须 之后<)>:
$("#barely_slide img[data-imgnum='"+ hash +"']").trigger("click"); // or .click()