Reputation: 41433
Hay i have a link like this
index.php?sometext=f,fsdsd,rerw,e,wewewe
and when i use .attr("href") on the link, it stops at the first comma, so it only displays
index.php?sometext=f
Any idea how to get ALL the href value
Upvotes: 1
Views: 2117
Reputation: 14967
$('a').each(function(i, el){
var href = $(this).attr('href');
if (href.split('?').length == 2) {
var dir = href.split('?')[0], query = href.split('?')[1];
$(this).attr('href', dir + '?' + encodeURI(query));
}
});
Upvotes: 0
Reputation: 881735
Commas are among the characters that should be urlencoded when present in a URL, that is, in their case, replaced with %2C
.
Upvotes: 0
Reputation: 28723
You should replace ,
with %2C
in your links. This is URL encoding.
Upvotes: 2