Posts

Showing posts from March, 2015

Change Text Color with Javascript at more that one part in single page.

Below code is the modified version of the topic name  Change Text Color with Javascript as one of the reader demands. Copy and paste the code in notepad and save it as any name with .html extension and run in browser. Logic behind to use the same feature in different parts of the page is by using class instead of id. Id is unique and cannot be used more than once but class can be used more than once to group the feature. The previous code uses ID and this one use Class on div. < html > < head >     < title > Text Color Change </ title >     < script type ="text/javascript" language ="javascript">         elmColor = 0;         function changeColor(elmColor) {             for (i = 0; i < document.getElementsByClassName( 'colorChange' ).length; i++) {                 switch (elmColor) {                     case 0:                         document.getElementsByClassName( 'colo