Skip to content Skip to sidebar Skip to footer

Using Javascript To Change Table Cells Width

My table td width in CSS is 150px. I am thinking of using JavaScript to change the particular td width to 2px. How can it be done?

Solution 1:

Something like this (for the first one:

document.getElementsByTagName('td')[0].style.width = '2px';

Or this for all:

var tds = document.getElementsByTagName('td');

for (var i = 0; i < tds.length; i++)
    tds[i].style.width = '2px';

Post a Comment for "Using Javascript To Change Table Cells Width"