Can’t control width of table elements added with jQuery

I used JavaScript for loops to create a 16×16 grid by appending elements to a table. This works fine, except I can’t control the width of the boxes via css – they always come out very narrow. I can style other aspects, including height, but altering the width property has no effect. I’ve tried messing with the display, margin, and padding properties, with various outcomes, but never anything useful.

Here’s my code.

Javascript

for (var r=0; r<16; r++) {
    $('table').append("<tr></tr>");
};
for (var c=1; c<16; c++) {
    $('tr').append("<td class='grid'></td>");
};

CSS

.grid {
height: 10px; width: 10px;
border: 1px solid black;
background-color: #eeeeee;
}


Download cant.control.width.of.table.elements.added.with.jquery.zip
Direct Link


Download


Download cant.control.width.of.table.elements.added.with.jquery.zip
Mediafire


Download


Download cant.control.width.of.table.elements.added.with.jquery.zip
4Upfiles


Download


Download cant.control.width.of.table.elements.added.with.jquery.zip
Solidfiles


Download


Download cant.control.width.of.table.elements.added.with.jquery.zip
Load.to


Download

Both comments and pings are currently closed.

Comments are closed.