tags:

views:

281

answers:

1

Here is my parent div,

<div id="ResultsDiv" class="resultsdiv">
 <br />
 <span id="EmployeeName" style="font-size:125%;font-weight:bolder;">Pandiyan</span>
 <span style="font-size:100%;font-weight:bolder;padding-left:100px;">Category&nbsp;:</span>&nbsp;
 <span>Supervisor</span><br /><br />
 <span id="SalaryBasis" style="font-size:100%;font-weight:bolder;">Salary Basis&nbsp;:</span>&nbsp;
 <span>Monthly</span>
 <span style="font-size:100%;font-weight:bolder;padding-left:25px;">Salary&nbsp;:</span>&nbsp;
 <span>25,000</span>
 <span style="font-size:100%;font-weight:bolder;padding-left:25px;">Address&nbsp;:</span>&nbsp;
 <span>Madurai</span>
</div>

alt text

How to add divs below this parent div using jquery,

function Iteratejsondata(HfJsonValue) {
    var jsonObj = eval('(' + HfJsonValue + ')');

    for (var i = 0, len = jsonObj.Table.length; i < len; ++i) {
        var employee = jsonObj.Table[i];

        //Add divs here based on length
    }
}
+1  A: 

You could use the insertAfter function:

$('<div>' + employee.SomeProperty +'</div>').insertAfter('#ResultsDiv');

This will insert a div for each emplyee just after the div#ResultDiv. If you want to insert divs inside the result div you could use the append method:

$('#ResultsDiv').append('<div>' + employee.SomeProperty +'</div>');
Darin Dimitrov
@Darin see my edit i have shown an image of my parent div...
Pandiya Chendur
@Darin insert after worked for me...
Pandiya Chendur
@Darin insert after adds my first record to last...
Pandiya Chendur