I want to render html table with two rows and one column. If the total count of records from HttpHandler is greater than 2 ,the extra record will be inserted behind the first column. Thank you in advance.
Html table will be rendered:
RealName RealName RealName
Name1 Name3 Name5
Name2 Name4
Here is my js snippet:
function fillSuccess(rsp) {
var str = "<table width='100%'><tr><td>RealName</td></tr>";
for (var i = 0; i < rsp.length; i++) {
if (i % 2 == 0) {
// how to implement here
}
else {
str += "<tr ><td>" + rsp[i].RealName + "</td>";
}
}
str += "</tr></table>";
$('#divTitle').append(str);
This should work with an odd or even count:
DEMO
http://jsfiddle.net/ZmHSY/