javascript - Replace Text with jQuery issue -
i'm having little trouble getting work correctly.
i have breadcrumbs following structure
<nav class="breadcrumb" > <a href="http://example.com">home</a> ">" <a href="http://example.com/category/mens/">mens</a> "> mens clothing" </nav>
which outputs to:
home>mens>mens clothing
i want:
home>mens>clothing
and code replacing last part of breadcrumb:
$(".breadcrumb").text(function(){ return $(this).text().replace("mens clothing", "clothing"); })
my problem code removes links , leaves me with"
<nav class="breadcrumb" > "home>mens>clothing" </nav>
with no links.
not sure why. please help
try using html()
instead of text()
:
$(".breadcrumb").html(function(){ return $(this).html().replace("mens clothing", "clothing"); });
Comments
Post a Comment