Jquery replace> character by html code
I am trying to change the arrow> ( >
) breading brackets to "using jquery.
<div id="breadcrumbs">
<a title="Go to cbc." href="http://cbcsales.co.il/newsite" class="home">Home</a>
> testpage</div>
I have tried using the following jquery. But the tag is missing. It replaces the character <a>
tag >
. Help me. Thanks to
jQuery("#breadcrumbs").text(function(index, text) {
return text.replace('>', 'ยป');
});
+3
source to share
5 answers
Just call replace
on the element itself, not inside the function:
Demo
jQuery("#breadcrumbs").html(
jQuery("#breadcrumbs").html().replace('>', 'ยป')
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="breadcrumbs">
<a title="Go to cbc." href="http://cbcsales.co.il/newsite" class="home">Home</a>
> testpage
</div>
+3
source to share