I have an HTML element that I wish to modify via Javascript. It contains a special character ©
.
If I leave the HTML alone, I get what I expect. In its original state, it is
<li id="cp">© MyCompany</li>
and then the line renders as "© MyCompany".
I want to auto-update that to display a range of years as the calendar changes, so I added some Javascript to the document's onload() function.
var today = new Date();
var cptext = "© 2011-" + today.getFullYear().toString() + " MyCompany";
$('#cp').text(cptext);
But then, when the page loads, the ©
is left as its original text, so the user sees the original $copy; 2011-2015 MyCompany
instead of what I want, which is "© 2011-2015 MyCompany". The automatic date range code works fine, but the normal symbol replacement goes away.
How can I get the symbol to be updated as it is in the static HTML when I use jQuery/Javascript to modify the DOM element?
I do not have the option of recoding the entire HTML page as PHP.