I've created cells for a dynamic table in html page using "document.createElement('td')" method & now wish to set width of each individual cell with some different value. Tried "cell.width = width" but it didn't work.
how can I achieve it?
I've created cells for a dynamic table in html page using "document.createElement('td')" method & now wish to set width of each individual cell with some different value. Tried "cell.width = width" but it didn't work.
how can I achieve it?
Share Improve this question asked Jan 18, 2013 at 8:59 user1976456user1976456 611 gold badge1 silver badge4 bronze badges 4 |2 Answers
Reset to default 12Use style.width
:
var cell = document.createElement('td');
parent.appendChild(cell);
cell.style.width = '200px';
Here is an example.
To post my comment as an answer:
Use cell.style.width = width;
.
cell.style.width = width
? Welcome to SO! – 11684 Commented Jan 18, 2013 at 9:01