Reputation: 7
refering to remove tags inside hyperlink using jquery
Sorry to bother but now I need to send an email from a hyperlink... unfortunately the previous solutions don't solve the problem :(
This fiddle work only with the email field
$(".MyClassID").find("a").attr("href", function(i, val) {
return val.replace("<span>", "").replace("</span>", "");
});
and this one is better but the body is uncomplete...
$("a").each(function (){
var id=$(this).attr("href").substring($(this).attr("href").indexOf("<span>"))
var k=$(this).attr("href").substring($(this).attr("href").indexOf("<span>"),0);
$(this).attr("href",k+$(id).text());
console.log($(this).attr("href"));
});
Can anybody help ?
Upvotes: 0
Views: 30
Reputation: 2843
Consider usage of regular expression http://jsfiddle.net/yxes3/15/
$(".MyClassID").find("a").attr("href", function(i, val) {
return val.replace(/<\/?span>/gi, "");
});
Upvotes: 2