-1

I am making a guide for one of my games that I play and I want to know if there is a way to italicize specific words that are typed multiple times without having to type <i> and </i> over and over again. I tried looking up how to but either I'm blind or I can't find how.

The_DemoCorgin
  • 744
  • 6
  • 19
Kurt Moon
  • 1
  • 1
  • Not with HTML alone. You could use JavaScript to find those words and put them into an `i` element automatically … but without any basic knowledge, this would be to broad to explain here. – CBroe Feb 24 '15 at 00:41
  • Ok, can you tell me which tutorial it would be? like Js loop or whatever it is? – Kurt Moon Feb 24 '15 at 00:47

1 Answers1

0

Must be done with javascript. Here you go...

var wordAr = ["quick", "fox",];
 
var theText = document.getElementById("theText").innerHTML;
 
for (i in wordAr) {
    theText = theText.replace(new RegExp(wordAr[i], 'g'), '<i>'+wordAr[i]+'</i>');
}
 
document.getElementById("theText").innerHTML = theText;
<div id="theText">
    The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</div>
Daniel Williams
  • 2,195
  • 7
  • 32
  • 53