menuOrder is an empty div
$("#menuOrder").append('<table>');
$(menus).each(function(i, menu) {
$("#menuOrder").append('<tr><td>');
$("#menuOrder").append(menu.text);
$("#menuOrder").append('</td><td>');
if (i > 0) {
$("#menuOrder").append('<img src="/images/_images/up.png" />');
} else {
$("#menuOrder").append('<img src="/images/_images/blank.png" />');
}
if (i < menus.length - 1) {
$("#menuOrder").append('<img src="/images/_images/down.png" />');
}
$("#menuOrder").append('</td>');
$("#menuOrder").append('</tr>');
});
$("#menuOrder").append('</table>');
this code not work properly, how can I change it with minimum iterations?
Try doing something like this:
This fills the
rowsarray with a string that contains the HTML for each row. When its done creating all the rows then it creates a jQuery Object of a table element and appends all the rows to it. It then appends the table to#menuOrder.