Jquery 如何实现加载完页面后自动将img和a中的地址替换
Jquery 怎么实现加载完页面后自动将img和a中的地址替换
如:
<img id="rptComment_ctl01_Gravatar1" width="60" height="60" src="http://www.gravatar.com/avatar.php?gravatar_id=f847fb8954f1750719d3feef3b033718&rating=G&size=60" />
将 src属性中"http://www.gravatar.com"内容替换为空,下过如下:
<img id="rptComment_ctl01_Gravatar1" width="60" height="60" src="/avatar.php?gravatar_id=f847fb8954f1750719d3feef3b033718&rating=G&size=60" />
------解决思路----------------------
$(function(){
$('img,a').each(function(){
if(this.tagName=="A")this.href=this.href.replace(/^http:\/\/www.gravatar.com/i,'')
else this.src=this.src.replace(/^http:\/\/www.gravatar.com/i,'')
})
})
------解决思路----------------------
如:
<img id="rptComment_ctl01_Gravatar1" width="60" height="60" src="http://www.gravatar.com/avatar.php?gravatar_id=f847fb8954f1750719d3feef3b033718&rating=G&size=60" />
将 src属性中"http://www.gravatar.com"内容替换为空,下过如下:
<img id="rptComment_ctl01_Gravatar1" width="60" height="60" src="/avatar.php?gravatar_id=f847fb8954f1750719d3feef3b033718&rating=G&size=60" />
------解决思路----------------------
$(function(){
$('img,a').each(function(){
if(this.tagName=="A")this.href=this.href.replace(/^http:\/\/www.gravatar.com/i,'')
else this.src=this.src.replace(/^http:\/\/www.gravatar.com/i,'')
})
})
------解决思路----------------------
$(function(){
$('img,a').each(function(){
if(this.tagName=="A")this.href=''
else this.src=''
})
})