I am working on a site that has an acronym in the content that require a registered trademark symbol. This content is added via a CMS. I am currently having problems with the special character sticking when entered via the CMS textfield (it turns into a ? if the CMS page is edited and resaved), which brings me to my question:
I would like to just enter the basic acronym via the CMS, like so: ACRONYM
and then use the JQuery .replaceWith feathure to add the registered trademark to the ACRONYM dynamically so it will return: ACRONYM
® in place of all instances of ACRONYM that exist within a container div that has a lot of other content like so:
- <div id="int-contentwrap">a bunch of text that should not be affected by the find and replace method. ACRONYM and some more text that should not be affected by the find and replace method.</div>
I tried the following example and it worked in my webpage, but when I tried to change the code to replace just a text string instead of the p tag it did not work. I did not see an example of this in the documentation. So is this possible with .replaceWith and how would I fashion the code to look for the ACRONYM only? or is there some other method that is better suited fro what I am trying to do?
- <p>this is a test. replace me.</p>
<script>
$("p").replaceWith( "<b>Paragraph. </b>" );
</script> - ACRONYM
<script>
$("ACRONYM").replaceWith( "ACRONYM<sup>®</sup>" );
</script>
Any advise is greatly appreciated! If someone could point me in the right direction... :)