所以我正在尝试学习 javascript,我想我有一个可以工作的 json 脚本,它带有一个循环来获取数据,但我无法弄清楚如何将数据附加到我的 div 中。在我弄清楚这一点后,我将在 jquery 中重做它(因为我也在努力学习)。
假设我的 div id 是#wrapper
for (var i = 0; i < providerlisting.length; i++) {
document.write('<div class="entry panel row"> \
<div class="large-4 columns first"> \
<div class="name">' + providerlisting[i].nametitle + '</div> \
<div class="specialty">' + providerlisting[i].caretype + '</div> \
<div class="peferred">' + providerlisting[i].preferredprovider + '</div> \
</div> \
<div class="large-3 columns second"> \
<div class="address">' + providerlisting[i].address1 + '<br /> \
' + providerlisting[i].address2 + '<br /> \
' + providerlisting[i].citystatezip + ' \
</div> \
</div> \
<div class="large-3 columns third"> \
<img src="' + providerlisting[i].coverage + '" alt="example"> \
</div> \
<div class="large-2 columns fourth"> \
<div class="status">' + providerlisting.status + '</div> \
<a data-dropdown="actionsMenu2" class="actions button small secondary round dropdown" href="#">Actions</a><br> \
<ul id="actionsMenu2" data-dropdown-content="" class="f-dropdown"> \
<li><a href="' + providerlisting[i].psn + '">Generate PSN</a></li> \
<li><a href="' + providerlisting[i].dcontact + '">Download Contact</a></li> \
<li><a href="' + providerlisting[i].save + '">Save to Provider List</a></li> \
<li><a href="' + providerlisting[i].rating + '">View Healthgrades Rating</a></li> \
</ul> \
</div> \
</div> \
')};