473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Child nodes

178 100+
Apologies in advance for being an idiot..

I have some javascript objects that are all children of a div "canvas". they all have a class="newObject". I want to setup a loop or something to perform an operation on each one. Can someone make a suggestion please?
Jul 17 '08 #1
1 1353
hsriat
1,654 Expert 1GB
Recently there's been introduced a new function called getElementsByClassName. But old browsers don't support it. So you can make your function work like this...
Expand|Select|Wrap|Line Numbers
  1. ....
  2. var canvas = document.getElementById('canvas'); //canvas referance
  3. var requiredEle = Array;//array of the elements you need
  4. if (document.getElementsByClassName) //check if the function is supported
  5. requiredEle = canvas.getElementsByClassName('newObject');
  6. else { //else find all the elements with that classname
  7.     var allEle = div.getElementsByTagName("*");
  8.     for(var i in allEle)
  9.     if (allEle[i].className = 'newObject')
  10.     requiredEle.push(allEle[i]);
  11. }
Jul 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: kaeli | last post by:
Can anyone explain this to me? It's driving me insane. Save this and run it in IE or Opera and then in Mozilla or Netscape 6+. In IE/Opera, I get the expected 4 alerts. In Mozilla/Netscape, I...
1
by: Hazz | last post by:
I have 5 tables in SQL Server. Each with the following design and a sample chain of the relationships from the root (WRL - World) UUS is the 'Code' of the first table and it is the 'Parent' value...
0
by: JJ | last post by:
Hi All, I am trying to Add nodes in code behind and am having problems with the parent child relationships. I get a Use of unassigned local variable error . I have the local variables defined...
12
by: Dino L. | last post by:
I am putting data from DataTable to treeView foreach( DataRow aRow in aTable.Rows) { TreeNode tnode = new TreeNode(aRow.ToString() + aRow.ToString() + " " + aRow.ToString());...
7
by: amruta | last post by:
the code below dows not let me get the parent child view... all the nodes are show in one line only... also i need them to be collasped ... Thanks ..
2
by: Jack | last post by:
Hello, I am trying use a TreeView with checkboxes. I would like to check more than one node and allow all child nodes of selected nodes to be checked or unchecked with the parent is checked. ...
1
by: Daniel Rucareanu | last post by:
Hello, Does anybody knows how can you delete, in just one step, not using a loop, a subset of the child nodes of a given DOM parent node? The subset will be continous, so for example, if the...
2
by: GreggaR0und | last post by:
Hello; I'm trying to iterate through the sub nodes of a child node, but I'm getting a compile error on the nested For...Next expression saying it is invalid. Using the below code, the HasChild()...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
2
by: arggg | last post by:
I am trying to add child nodes based on database query in which the users in the database are a part of the parent node. Here is my code. private void GetUsersByGroup() { ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.