我想从href属性javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8')
中删除 javascript:ShowExternal ,我想从href属性中获取唯一的网址,那我该怎么做。
<a style="color:Blue;text-decoration:underline;" href="javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3A779')" class="cmn" id="ctl00_cntPlcHld1_lstvwSurveys_ctrl14_hlsurvey">View</a>
答案 0 :(得分:1)
这可能会对您有所帮助:
var temp = "javascript:ShowExternal('http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8')";
trm = /\((.*)\)/i;
console.log(temp.match(trm)[1]);
它会给你输出:
'http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3B9A8'
答案 1 :(得分:1)
点击查看链接即可获取网址
$(document.body).on('click',"a",function(event){
var temp =$(this).attr("href") ;
trm = /\((.*)\)/i;
console.log(temp.match(trm)[1]);
});
输出将是:
&#39; http://www.hhgsurvey.com/CustomerSurveyReport.aspx?SurveyID=M3A779&#39;
答案 2 :(得分:1)
尝试这样Demo Here
var text = $('a').attr('href');
var result = text.replace('javascript:ShowExternal(','');
console.log(result.slice(0,-1));