[Javascript] styling text

Scott Reynen scott at randomchaos.com
Fri Nov 30 21:23:50 CST 2007


On Nov 30, 2007, at 6:20 PM, Scott Petersen wrote:

> I want to take this markup:
>
> 	<div id="theList">
> 		<ol>
> 			<li>
> 				<span>dirty</span>
> 				<span>汚い</span>
> 				<span>I have to clean my room. It is dirty.</span>
> 			</li>
> 		</ol>
> 	</div>
>
> and color the word "dirty" in the sentence blue, or set it off in
> some other way.

> I  thought I might try to let javascript do the work.
>
> Any thoughts?


document.getElementById( 'theList' ).getElementsByTagName( 'li' ) 
[0].getElementsByTagName( 'span' )[0].className = 'blue';

Peace,
Scott




More information about the Javascript mailing list