SetStyleByClass function





6
Date Submitted Mon. Nov. 6th, 2006 9:22 AM
Revision 1 of 1
Scripter Casper42
Tags Class | CSS | Style
Comments 5 comments
This function sets a particular style for an element based on it's class

function setStyleByClass(objClass,objProperty,objValue){
//  This function will apply a style to an Element based on Class
//  Works with IE and Mozilla based browsers
//  2005-10-25: Jeremy Edmiston
        var elements = (ie) ? document.all : document.getElementsByTagName('*')
        for(var i = 0; i < elements.length; i++){
                if(elements[i].className == objClass) {
                        //eval('elements[i].style.' + objProperty + " = '" + objValue + "'");
      elements[i].style[objProperty] = objValue;                       
                }
        }
}
 

Jeremy Edmiston

Comments

Comments Used for dynamic effects.
Tue. Nov. 21st, 2006 2:30 PM    Scripter Casper42
Comments Another version
Mon. Nov. 6th, 2006 3:49 PM    Helper brendo
  Comments I found this very script
Sun. Jan. 7th, 2007 9:18 PM    Newbie rodneyj
Comments isn't this basically CSS?
Wed. Nov. 8th, 2006 2:09 PM    Newbie korisu
  Comments It has uses :)
Wed. Nov. 8th, 2006 7:06 PM    Helper brendo

Voting