我已经设置了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