jQuery: RegExp for all occurances; Wrap all © and ® with HTML

March 26th, 2010
|

This script will find all © and ® on a page and wrap them a span around them with a “copy” or “reg” class accordingly.

<style>
.copy, .reg {font-size:xx-small;vertical-align:text-top;}
</style>

<script>
$(function(){
var copy = new RegExp(‘\u00a9′,’g’);
var reg = new RegExp(‘\u00ae’,’g’);
var newBody = $(‘body’).html().replace(copy, ‘<span class=”copy”>&copy;</span>’).replace(reg, ‘<span class=”reg”>&reg;</span>’);
$(‘body’).html(newBody);
});
</script>

Tags: , , , ,

Comments are closed.

Comments have been closed for this post. If you would like to ask a question or need help, please post in the forums.