I want to know how to select particular td in table.
$.each(result.HotelSearchResult.HotelResults, function (index, item) {
var imgPath = item.HotelPicture;
var rate = item.StarRating;
var table = $('#tableId');
var rows = '<tr><td rowspan="4" width="16.666%"><img src="' + imgPath + '" />'+ "</td>";
rows += '<tr><td class="code">' + addScore(rate, $("td.code")) + "</td></tr>";
table.append(rows);
});
Here, addScore
is a function and it requires an element as its second parameter to append stars according to rating. I am following this post, but in my code it is appending all the ratings to particular td
for each iteration. This means if there are 20 arrays then its appending 20 ratings to each td
in the table. I want to append one rating per td
.
This is my table:
<div id="divResult5"></div>
<table>
<tr></tr>
<tbody id="tableId" style="border:solid 1px red;"></tbody>
</table>
Please tell me how it should be done.