2013-07-21 92 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