Find apostrophe's and replace with some other character
I am stuck with a problem, which has got to do with Apostrophe's. How do i find and replace all apostrophe's with some other character. The code is as follows.
Script
jQuery('.note').each(function() {
var final = jQuery(this).text();
jQuery(this).html('<div class="solutionnotes">'+final+'</div>');
var htmlElement = jQuery('.solutionnotes').text();
var e = htmlElement;
alert(e);
e.replace(/\&apos;/g, "acute;");
});
HTML Code
<body>
<div class="note">&apos; &apos; &apos; Test 1 &apos; &ap开发者_JAVA技巧os;</div>
<div class="note">&apos; &apos; &apos; Test 1 &apos; &apos;</div>
<div class="note">&apos; &apos; &apos; Test 1 &apos; &apos;</div>
</body>
Try this:
jQuery('.note').each(function() {
var final = jQuery(this).text();
jQuery(this).html('<div class="solutionnotes">'+final+'</div>');
var htmlElement = jQuery('.solutionnotes').text();
var e = htmlElement.replace(/&apos;/g, "HELLO");
alert(e);
});
精彩评论