jQuery Superscript all registered marks

This small jQuery snippet will wrap all registered marks in a superscript element. This is handy when you have many static HTML files and are unable to do it via database, or your site runs on a CMS and you need to keep registered marks superscripted, regardless of how it's entered by the CMS user.
var re = new RegExp(String.fromCharCode(174), 'g');
var html;
$('h1,h2,#any-other-tag-that-might-have-one').each(function() {
	html = $(this).html();
	if (html) {
		html = html.replace(re, '<sup>®</sup>').replace(/®/gi, '<sup>®</sup>');
		$(this).html(html);
	}
});
Posted by
Snippet Viewed 8414 times.

Share your jQuery code snippets:

  • Get some recognition & link back to your site.

 

Submit | Browse

Most Recent jquery snippets

Most Viewed