I have created a parent div and inserted div's after the parent div using jquery insertAfter()
method.... What happens is My first record goes to the bottom and next record gets inserted above it....
Here is my function...
function Iteratejsondata(HfJsonValue) {
var jsonObj = eval('(' + HfJsonValue + ')');
for (var i = 0, len = jsonObj.Table.length; i < len; ++i) {
var employee = jsonObj.Table[i];
$('<div class="resultsdiv"><br /><span id="EmployeeName" style="font-size:125%;font-weight:bolder;">' + employee.Emp_Name + '</span><span style="font-size:100%;font-weight:bolder;padding-left:100px;">Category :</span> <span>' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" style="font-size:100%;font-weight:bolder;">Salary Basis :</span> <span>' + employee.SalaryBasis + '</span><span style="font-size:100%;font-weight:bolder;padding-left:25px;">Salary :</span> <span>' + employee.FixedSalary + '</span><span style="font-size:100%;font-weight:bolder;padding-left:25px;">Address :</span> <span>' + employee.Address + '</span></div>').insertAfter('#ResultsDiv');
}
}
And my result is,
Palani must be next to my parent div but it is at the bottom... Because insertAfter()
inserts every record next to the #ResultsDiv
... Any suggestion how to insertafter the newly generated div...
EDIT: how to add row color to these divs i used
function Iteratejsondata(HfJsonValue) {
var jsonObj = JSON.parse(HfJsonValue);
for (var i = jsonObj.Table.length - 1; i >= 0; i--) {
var employee = jsonObj.Table[i];
$('<div id="resDiv" class="resultsdiv"><br /><span id="EmployeeName" style="font-size:125%;font-weight:bolder;">' + employee.Emp_Name + '</span><span style="font-size:100%;font-weight:bolder;padding-left:100px;">Category :</span> <span>' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" style="font-size:100%;font-weight:bolder;">Salary Basis :</span> <span>' + employee.SalaryBasis + '</span><span style="font-size:100%;font-weight:bolder;padding-left:25px;">Salary :</span> <span>' + employee.FixedSalary + '</span><span style="font-size:100%;font-weight:bolder;padding-left:25px;">Address :</span> <span>' + employee.Address + '</span></div>').insertAfter('#ResultsDiv');
}
$("#resDiv.resultsdiv:odd").css("background-color", "#F4F4F8");
$("#resDiv.resultsdiv:even").css("background-color", "#EFF1F1");
}
But didnt work..