开发者

Find apostrophe's and replace with some other character

开发者 https://www.devze.com 2023-01-16 00:31 出处:网络
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.

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(/\&amp;apos;/g, "acute;");
    });

HTML Code

<body>
<div class="note">&amp;apos; &amp;apos; &amp;apos; Test 1 &amp;apos; &amp;ap开发者_JAVA技巧os;</div>
<div class="note">&amp;apos; &amp;apos; &amp;apos; Test 1 &amp;apos; &amp;apos;</div>
<div class="note">&amp;apos; &amp;apos; &amp;apos; Test 1 &amp;apos; &amp;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(/&amp;apos;/g, "HELLO");
         alert(e);
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消