Q:

How to count attribute which have same value in HTML with javascript?

I have following code of HTML,
<table>
<tr>
<td>content</td>
<td>content</td>
</tr>
<tr>
<td colspan="2">one</td>
</tr>
<tr>
<td>content</td>
<td>content</td>
</tr>
<tr>
<td colspan="2">two</td>
</tr>
<tr>
<td>content</td>
<td>content</td>
</tr>
<tr>
<td colspan="2">three</td>
</tr>
</table>

What I really want is to count the "colspan", and take the those contents from those table with JavaScript only, no jquery and mootool please. Thanks you. 
I have got the answer for this, can we optimize to be shorter code or just simply the code?
var tds = document.getElementsByTagName( 'td' );
var colspanCount = 0;
var valuecount = 0;
for( i=0; i<tds.length; i++ ) {
    myvalue = (tds[i].hasAttribute( 'colspan' ));
    if (myvalue == true) {
     valuecount += 1;
    }

}
document.write('my value is ' + valuecount);

A:

I think using jQuery would be best, but something like this should work:
var tablecols = document.getElementsByTagName("td");
for(var i in tablecols) {
    if (tablecols[i].getAttribute('colspan') != undefined) {
        alert(tablecols[i].innerHTML);
    }
}

Please note that this is untested.  

