...

View Full Version : looping through divs ?



paulweb
12-18-2006, 07:04 PM
i need to be able to get all the divs with a certain id name and loop through them and not show them .. (id names will always have the word add in them. like , add1 , add2, add3, etc..)

i dont know how many adds there will be for each page (this will be dynamic and different throughout the site)..

so i dont know how to get the number of divs that contain the word add in their id....

any ideas?

Basscyst
12-18-2006, 07:19 PM
The following will work but it will also match if you have "add" in any shape or form in the id ex. id="badder".



var divs=document.getElementsByTagName('div');
var len=divs.length;
for(var i=0;i<len;i++)
{
d_id=divs[i].getAttribute('id');
if(d_id.indexOf('add')!=-1)
{
alert("I have add in my id");
}
}

paulweb
12-18-2006, 09:51 PM
anddddddddddddddd thank u



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum