2013-07-21 90 views

回答

2

使用replaceWith

$('a').replaceWith(function() { 
    return $('<img/>').attr('src', this.href); 
}); 

更換'a'與選擇的您需要替換的鏈接。

+0

+1我總是*忘記那種形式(傳遞函數)與我不經常使用的方法(如'replaceWith')。 *嘆息* –

+0

@ T.J.Crowder - 我也是。直到大約兩天左右,當我在幾個小時內看到5或6個答案時,所有在這裏都使用了這種技術。 :) – techfoobar

+0

這就是我一直在尋找,thx :) – user2587741