The code you enter will receive the value as a string , and then correctly replace values, but immediately cancel the result. You need to pass the replaced value to attr . Try the following
$('a').each(function() { var value = $(this).attr('href'); $(this).attr('href', value.replace('#/','')); });
Jaredpar
source share