I have HTML markup like this:
<div class="row"> <div class="cell" id="jobtitle"></div> <div class="cell" id="jobname"></div> <div class="cell" id="fullname"></div> <div class="cell" id="phone"></div> <div class="cell" id="mail"></div> <div class="cell" id="city"></div> <div class="cell" id="description"></div> </div> which if had data would looks like:
And I have jQuery code:
$.ajax({ type: 'POST', url: 'query2.php', data: key, dataType: 'json', success: function (msg) { var html = ["", "", "", "", "", "", ""] , cnt = 0; $.each(msg, function () { html[0] += '<div>' + msg[cnt].jobTitle + '</div>'; html[1] += '<div>' + msg[cnt].jobName + '</div>'; html[2] += '<div>' + msg[cnt].fullName + '</div>'; html[3] += '<div>' + msg[cnt].phone + '</div>'; html[4] += '<div>' + msg[cnt].mail + '</div>'; html[5] += '<div>' + msg[cnt].city + '</div>'; html[6] += '<div>' + msg[cnt].description + '</div>'; cnt++; }); $('#jobtitle').html(html[0]); $('#jobname').html(html[1]); $('#fullname').html(html[2]); $('#phone').html(html[3]); $('#mail').html(html[4]); $('#city').html(html[5]); $('#description').html(html[6]); } If the query returns on row, my table would be like:
But if it has multiple rows, it doesn't show right:
And if I don't use div in my jQuery, all data would show attached together.
How can I print multiple rows in correct show in div like the first picture?
Update:
<html> <body> <div class="form-style-5 read-style"> <fieldset class="field-read"> <input id="inputsearch" type="text" name="searchbox" placeholder="بخشی از متن جهت جستجو" Lang="fa-IR"> </fieldset> </div> <div class="wrapper"> <div class="table"> <div class="row header blue"> <div class="cell table-header"> کسب و کار </div> <div class="cell table-header"> عنوان شغل </div> <div class="cell table-header"> نام و نام خانوادگی </div> <div class="cell table-header"> تلفن </div> <div class="cell table-header"> آدرس ایمیل </div> <div class="cell table-header"> شهر </div> <div class="cell table-header"> توضیحات </div> </div> <div class="row"> <div class="cell" id="jobtitle"></div> <div class="cell" id="jobname"></div> <div class="cell" id="fullname"></div> <div class="cell" id="phone"></div> <div class="cell" id="mail"></div> <div class="cell" id="city"></div> <div class="cell" id="description"></div> </div> </div> </body> </html> And the CSS I have:
.cell { padding: 6px 12px; display: table-cell; font-family: yekan; font-size: 14px; text-align: center; } .row { display: table-row; background: #f6f6f6; } .row:nth-of-type(odd) { background: #e9e9e9; } .wrapper { margin: 0 auto; padding: 10px; max-width: 100%; } .table { margin: 0 0 40px 0; width: 100%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); display: table; } Which like the first picture i inserted, all are centered, odd and even rows has different colors. But in the div in the jQuery loop, CSS isn't working.



divs?