Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Class

Status
Not open for further replies.

DANZIG

Technical User
Mar 8, 2001
142
US
Hello

Is there anything similar to document.getElementByID but using the class attribute? IE document.getClassByID


Thanks, Danzig
 
i've used this script before:

Code:
function getElementsByClassName(className){
   var allObjects;
   var newObjects = new Array();
   var j = 0;

   if (document.all) {
      allObjects = document.all;
   } else if (document.getElementsByTagName && !document.all) {
      allObjects = document.getElementsByTagName("*");
   }

   for (i = 0; i < all_obj.length; i++) {
      if (allObjects[i].className == className) {
         newObjects[j] = allObjects[i];
         j++;
      }
   }

   return newObjects;
}


tigerjade :)




"Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live." -- Martin Golding


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top