PDA

View Full Version : add classname to all of a tag


Tails
03-06-2003, 12:34 AM
Is it possible to add a className to specific tags on a page by their
index? I tried a loop like this and the property is not supported.

document.all("IMG")[0].className=="drag"

cheesebagpipe
03-06-2003, 12:39 AM
var img, i = 0, allIMGs = document.getElementsByTagName('img');
while (img = allIMGs.item(i++)) img.className = 'drag';