2012-05-15 38 views
1

我已經看到一些好的腳本來了,但沒有一個我真的可以使用。 我的網站是php sql驅動的,我喜歡用圖片 從縮略圖更改網站上的鏈接。 我的代碼到目前爲止是:將href鏈接轉換爲使用縮略圖的圖片鏈接

<a href="<?php echo $link['url'] ;?>"><?php echo openld_htmlspecialchars($link['title']); ?></a> 

並儘可能腳本我有去,如:

$('.post-body a').each(
    function(){ 
     $('<img />').attr('src','http://open.thumbshots.org/image.aspx?url='+encodeURIComponent(this.href)).replaceAll($(this)); 
    }); 

我用了.replaceAll功能,但只顯示圖片,而不是點擊鏈接。 我用.insertAfter但是文本鏈接不斷顯示。

這可能不是腳本代碼的巨大變化,但我似乎沒有在我的問題上找到答案。

感謝

回答

0

我希望你在找什麼...

$('.post-body a').each(function(){ 
    $(this).html("<img src='http://open.thumbshots.org/image.aspx?url="+encodeURIComponent(this.href)">"); 
}); 
+0

但是,在這不走? http://open.thumbshots.org/image.aspx?url='+encodeURIComponent –

+0

你現在可以看到更新... –

+0

感謝您的快速響應,我會立即檢查它。 –