I have some text I wish to replce using jquery. the problem is, is that this text is not within it's own element, the content is dynamic and I can not access HTML the markup to make things easier.
I can detect and replace the text in question, but I have only managed to replace it with a new text node, therefore it treats my html tags as text and not markup
DEMO http://jsfiddle.net/XvTgP/
$('div.myDiv').contents().filter(function () {
return this.nodeType == 3
}).each(function () {
this.textContent = this.textContent.replace('my old text no in its own element', '<div class="newClass">my new text</div>');
var myNewNode = this.textContent;
return
});
CURRENT OUTPUT AS TEXT
<div class="newClass">my new text</div>