Skip to content

Instantly share code, notes, and snippets.

@HeikoMamerow
Created October 31, 2014 12:33
Show Gist options
  • Save HeikoMamerow/b9366983d118c72fd294 to your computer and use it in GitHub Desktop.
Save HeikoMamerow/b9366983d118c72fd294 to your computer and use it in GitHub Desktop.
Mark first character of each word
function first_character() {
var str = document.getElementsByClassName("text")
for (var i = 0; i < str.length; i++) {
str[i].innerHTML = str[i].innerHTML.replace(/\b[a-z0-9]/gi, "<span class='first-char'>$&</span>")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment