Javascript function to get the matching value of html cells to show hierarchy(expand/collpase)
<p>I am dynamically creating an html table using asp.net and the page source is below.</p>

<pre><code>&lt;table id="MainTable" border="2" class="tdclass"&gt;
    &lt;tr&gt;
        &lt;th&gt;&lt;img src="arrow.png"  /&gt;&lt;/th&gt;
        &lt;td colspan="4"&gt;Title 1&lt;/td&gt;
        &lt;td id="1" style="Display:none"&gt;1&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;th&gt;&lt;img src="arrow.png"  /&gt;&lt;/th&gt;
        &lt;td colspan="3"&gt;Title 2&lt;/td&gt;
        &lt;td id="2" style="Display:none"&gt;2&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;th&gt;&lt;img src="arrow.png"  /&gt;&lt;/th&gt;
            &lt;td colspan="2"&gt;Title 3&lt;/td&gt;
        &lt;td id="3" style="Display:none"&gt;3&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
</code></pre>

<p>I want to compare the td id values of each row with all other td in each row. For example, in the above code, the first row contains the td id value as 1. So this has to be compared with all the other td elements of all the rows. Here the second row contains the matching element which is 1.<br>
So how to write a javascript function to loop through all the rows and find the match? The matching values actualy belongs to child element. So if any match occurs then i can display that row and make the rest of the rows hide. If my question is not clear please let me know.
I have achieved till this.
<img src="http://i.stack.imgur.com/AdlA8.png" alt="enter image description here"></p>
