我已經嘗試了很多事情來獲得這個工作,我基本上試圖讓燈箱照片顯示(它它),當點擊時,打開使用指定的URL創建新選項卡。 我試圖鏈接到新選項卡中的網址的圖像是「images/ad1.jpg」,它在代碼中。請告訴我正確的代碼和它需要輸入的方式,以便我可以做到這一點。我非常感謝大家支持這個和stackoverflow的偉大社區。謝謝。使用jquery在點擊時有圖像鏈接到新標籤中的URL
(function($){
$(window).load(function(){
if(jQuery.isFunction(jQuery.fn.prettyPhoto)) {
$.prettyPhoto.open(
"images/ad1.jpg", // Image to be opened
"title", // Title of the pop-up
"desc." // The description
);
setTimeout(function() {
$.prettyPhoto.close();
}, 10000); // autoclose after 10 seconds
} else {
console.log("PrettyPhoto is not defined."); // log this message
}
});
})(jQuery);
僅供參考:您在函數調用中將'$'定義爲'jQuery',然後在您的代碼中將其引用爲'jQuery'。雖然這確實起作用,但它有點違背了以'$'傳遞它的目的。 – 2014-08-28 15:27:20
下面的解決方案是否適合您?任何反饋? – 2014-08-30 16:01:18