I would like to find some specific text with jquery and replace it with an updated version, including some HTML.
I tried this one , which works when I use only text:
<script type="text/javascript" >
jQuery(document).ready(function(){
jQuery("*").contents().each(function() {
if(this.nodeType == 3)
this.nodeValue = this.nodeValue.replace("hello mum", "bye bye mum");
});
})
</script>
However, if I add text + HTML to replace the target expression, it gets βformattedβ and reads like plain text ...
Do you guys know any solution to this problem? Is it possible to add HTML to a replacement expression?
Thank.
source
share