JavaScript function to replace text in a div character by character.