Am I using the jquery appendTo method correctly in the code below?
I ask because it displays correctly when I test it in jsfiddle , but when I use the same code on my local server (in FF, IE and Chrome) it displays with elongated fields:




I assume that I am doing something wrong. Thanks.
HTML
<div class="ws-css-table" > <div class="ws-css-table-tr"> <div class="ws-css-table-td"></div> <div class="ws-css-table-td"></div> </div> <div class="ws-css-table-tr"> <div class="ws-css-table-td"></div> <div class="ws-css-table-td"></div> </div> <div class="ws-css-table-tr"> <div class="ws-css-table-td"></div> <div class="ws-css-table-td"></div> </div> </div> <br/> <button id="css-icol">Col +</button><br/><br/>
JQuery
$('#css-icol').click(function(){ $(".ws-css-table-td:last").clone().appendTo('.ws-css-table-tr'); var tblArr = $('.ws-css-table > .ws-css-table-tr').map(function () { return $(this).children().map(function () { return $(this); }); }); lastCol = $('.ws-css-table-tr:first > .ws-css-table-td').length; for (r=0; r<$('.ws-css-table-tr').length; r++) tblArr[r][lastCol-1].text('X'); });
CSS
.ws-css-table { display: table; } .ws-css-table-tr { display: table-row; } .ws-css-table-td { display: table-cell; border:1px solid #000; width: 15px; height:15px; text-align:center; vertical-align:middle; }
jquery html css wordpress
user1763812
source share