im tratando de cambiar href con cada método,¿Cómo reemplazar el attr href del elemento con cada uno? // url tira
here is demo, inspect a, you'll see there is no change
html:
<a href="#/news">News</a>
<a href="#/news/detail">Detail</a>
<a href="#/sport">Sport</a>
<a href="#/sport/football">Football</a>
jQuery:
$('a').each(function() {
$(this).attr('href').replace('#/',''); //tried to erase #/ from all hrefs
});
No se puede reemplazar la cadena de Attr como esa; acaba de obtener el href como variable con attr como getter, haz el reemplazo y luego vuelve a bombearlo de nuevo con attr como setter. (o como elclanrs, ¡supongo que puedes hacer el setter todo en uno!). –