我已經設置了pdf鏈接。我只是希望在我當前使用jQuery的href前加上Google的語法。我知道以下方法行不通,但我覺得我很接近......?使用jQuery與Google Docs打開PDF鏈接
jQuery(document).ready(function() { jQuery("a[href$=.pdf]").attr("href", "http://docs.google.com/viewer?url=" + current.href); });
反正可以幫忙嗎?
我已經設置了pdf鏈接。我只是希望在我當前使用jQuery的href前加上Google的語法。我知道以下方法行不通,但我覺得我很接近......?使用jQuery與Google Docs打開PDF鏈接
jQuery(document).ready(function() { jQuery("a[href$=.pdf]").attr("href", "http://docs.google.com/viewer?url=" + current.href); });
反正可以幫忙嗎?
只要你在原始文件中有絕對的網址,下面的內容應該可以工作。
$(document).ready(function() {
$("a[href$='.pdf']").each(function(){
$(this).attr('href', 'http://docs.google.com/viewer?url=' + $(this).attr('href'));
});
});
難道你不是指'this.href'而不是'current.href'? – 2010-04-06 03:56:07