0

I am using a script that gives the first letter of a word a different font color. But somehow it keeps escaping some charters i.e. & to &Amp; in Chrome and Safari. Can anyone help me with this and show me what to alter to have this displayed correctly?

<!--=== First Font Orange ===-->
<script>      
        window.onload = function(){
  var elements = document.getElementsByClassName("each-word")
  for (var i=0; i<elements.length; i++){
    elements[i].innerHTML = elements[i].innerHTML.replace(/\\b([a-z])([a-z]+)?\\b/gim, "<span class='font-orange'>$1</span><span style='text-transform:lowercase;'>$2</span>")
  }
}
</script>

Thank you in advance!

Wesley

wezzlee
  • 1
  • 2
  • http://stackoverflow.com/questions/4338963/convert-html-character-entities-back-to-regular-text-using-javascript –  May 24 '16 at 14:46
  • [Using regex to parse html](http://stackoverflow.com/a/1732454/5054380) – Bald Bantha May 24 '16 at 14:57

0 Answers0