I have text in a div with each character of my text enclosed in span tag:
Text = A quick brown fox jumps
<div id="span_text">
<span>A</span><span> </span><span>q</span><span>u</span><span>i</span><span>c</span><span>k</span><span> </span><span>b</span><span>r</span><span>o</span><span>n</span><span> </span><span>f</span><span>o</span><span>x</span><span> </span><span>j</span><span>u</span><span>m</span><span>p</span><span>s</span>
</div>
The problem is that the words do not wrap around since each character is enclosed in span tag. Is there any way to wrap text like in MS Word and other editors while having characters enclosed in span ???
Why do I need to enclose each character in span?
Actually I am making a basic typing tutor. Whenever a key is pressed, I have to:
- Highlight the character in Gray if valid character was typed.
- Highlight the character in Red if wrong character was typed.
- Highlight the next character to type is Green.
So to target each character, I have to enclose them in span and give each span unique ID to select them via jQuery.