为了账号安全,请及时绑定邮箱和手机立即绑定

请问下面的语句怎么通过替换?如果是正则,该怎么写?大概有500行左右。

请问下面的语句怎么通过替换?如果是正则,该怎么写?大概有500行左右。

 <a href="http://qhd.tuniu.com" onclick="_gaq.push(['_trackEvent', '首页_wh','点击','选预定城市_华北_秦皇岛']);">秦皇岛</a>                        <a href="http://wf.tuniu.com" onclick="_gaq.push(['_trackEvent', '首页_wh','点击','选预定城市_华北_潍坊']);">潍坊</a>                        <a href="http://zjk.tuniu.com" onclick="_gaq.push(['_trackEvent', '首页_wh','点击','选预定城市_华北_张家口']);">张家口</a>                        <a href="http://chzh.tuniu.com" onclick="_gaq.push(['_trackEvent', '首页_wh','点击','选预定城市_华北_长治']);">长治</a>全部替换成<a href="#">这里不变</a>
查看完整描述

2 回答

?
jerame

TA贡献20条经验 获得超25个赞

<script>
var a=document.getElementsByTagName('a');
window.onload=function(){
for (var i=0; i<a.length; i++) {
a[i].setAttribute("href","#");
a[i].removeAttribute("onclick");
}
}
</script>

用HTML DOM实现

查看完整回答
反对 回复 2016-05-22
  • 2 回答
  • 0 关注
  • 1937 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信