Replacing copyright/registered symbols with superscripted html

admin

Administrator
Staff member
I am developing a website for a manufacturing client. They are particularly picky when it comes to utilizing their copyright, registered and trademark symbols for their products/technologies according to how the government says they should be used. Consequently they a number of marks throughout their copy. They insist that the marks be superscripted. I could fix this manually per page, but would rather incorporate a short script that will do it for me. Especially on the basis that they may be creating and adding new content in the future on their own. The site is developed on wordpress.

I have a partial solution, which is the below code.

Code:
       $(function() {
            $('h1,p,a,span,li,dl,td').each(function(i, elem) {
                $(elem).html(function(i, html) {
                    return html.replace(/\u00ae/, "<sup>®</sup>");
                });
                $(elem).html(function(i, html) {
                    return html.replace(/\u00a9/, "<sup>©</sup>");
                });
            });
        });

This works perfectly for the first instance of these characters in the copy. However, if there are more than one symbol in each page, the above code applies only to the first instance. I need to make this recursive so it finds ALL instances, and changes appropriately.

How do I need to modify the above script to make the change happen to multiple instances? <strong>OR</strong> Is my approach above wrong/inefficient and I should instead be using [X]?