I am using this code to highlight each word one by one in a html document, but it is not that good method.
And It faces some problem for some words, if white space between two word is more than one, or if return character is encountered more than once
That's still not enough of a description for us to help. What constitutes a word? And where? In attributes? Content only? You seem to have some animation code in there; your description doesn't mention animation.
This seems like an academic exercise. Is it homework?
Why aren't you using jQuery to make this all much easier?
Joined: Mar 22, 2005
There's code to deal especially with IE4 Seriously, wherever you got that code from, never again go there.
Joined: Feb 06, 2011
Suppose I have Paragraph tag which contains some string like-
Here, word is a sequence of character separated by white space, so here words are-A,friendly,place,for,programming,greenhorns,Big,Moose,Saloon
Now I need to change the background color of each word starting from "A" to "Saloon", one by one.