Dick Applebaum wrote:
> What if you want to change the attributes of some related items?
> 
> Say you have table cells:
> 
> <tr>
>    <td id="col1">row 1 column 1</td>
>    <td id="col2">row 1 column 2</td>
> </tr>
> <tr>
>    <td id="col1">row 2 column 1</td>
>    <td id="col2">row 2 column 2</td>
> </tr>
> *
> *
> *
> 
> You can change the column width for all cells in the column with:
> 
>    document.getElementById("col1").style.width = 100;

Maybe you can, but it is illegal to have multiple elements with 
the same id.


> You can't accomplish this with class because there is no 
> getElementByClass method

whatever = document.getElementByTagName("tr");
for (var i = 0; i < whatever.length; i++) {
        whatever[i].firstChild.style.width = 100;
}

Or if you insist on using a class:

whatever = document.getElementByTagName("tr");
for (var i = 0; i < whatever.length; i++) {
        swapClass(whatever[i].firstChild, "some_100px_class");
}

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Sams Teach Yourself Regular Expressions in 10 Minutes  by Ben Forta 
http://www.houseoffusion.com/banners/view.cfm?bannerid=40

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:182041
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to