[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

count number of child tags

Posted on 2006-11-20
2
Medium Priority
?
2,464 Views
Last Modified: 2008-01-09
Hello experts:

Is there an easy way to count the number of child tags an html tag has?

For example, I want to know the number of columns for this row in a table (in this case, it is three, but I want to write a for loop that goes through each of the tds in a table where I don't know the column amount):

<tr id="some_row">
   <td>value 1</td>
   <td>value 2</td>
   <td align="center">value 3</td>
</tr>

Thanks in advance for your help
0
Comment
Question by:freezegravity
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 1000 total points
ID: 17982605
<table>
<tr id="some_row">
   <td>value 1</td>
   <td>value 2</td>
   <td align="center">value 3</td>
</tr>
</table>
<script type="text/javascript">
var TR=document.getElementById("some_row")
var TD=TR.getElementsByTagName("td")
alert(TD.length)
</script>
0
 

Author Comment

by:freezegravity
ID: 17982789
Works great!

Thanks a bunch!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question