Answer the question
In order to leave comments, you need to log in
What is the difference and which is better?
var body = $('#items').find('tbody'), i = 0, temp;
body.empty();
if (res.length > 0) {
for (; i < res.length; i++) {
temp = $('<tr>');
temp.append($('<td>' + res[i]['name'] + '</td>'));
temp.append('<td>' + res[i]['price'] + '</td>');
body.append(temp)
}
} else {
body.append($('<tr><td colspan="2" class="text-center">Товары отсутствуют</td></tr>'))
}
temp.append($('<td>' + res[i]['name'] + '</td>'));
temp.append('<td>' + res[i]['name'] + '</td>');
Answer the question
In order to leave comments, you need to log in
It doesn't matter (except perhaps an extra "waste of resources" for calling $ when it's not needed), it's just that the append method understands this and that.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question