Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    looping through divs ?

    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?

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    The following will work but it will also match if you have "add" in any shape or form in the id ex. id="badder".

    Code:
    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");
    	}
    }
    Helping to build a bigger box. - Adam Matthews

  • #3
    New Coder
    Join Date
    Dec 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    txs mr script

    anddddddddddddddd thank u


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •