我需要寻求帮助。 拥有此代码:在jquery循环中生成多个div
$(".apprezzamenti").click(function()
{
var id = $(this).attr('id');
$.get("http://localhost/laravel/public/index.php/apprezzamenti_modal/"+id,
function(data)
{
data_parsed = JSON.parse(data);
// BELOW is the loop that I would like to generate multiple div using .append()
for(var i=0; i<data_parsed.length; i++)
{
var html = '<img src="images/provvisorie/immagine-profilo.png" width="30px" and height="30x" />';
html += ' ';
html += "<a href='http://localhost/laravel/public/index.php/utente/" + data_parsed[i].id_user + "' style='font-weight: bold;'>" + data_parsed[i].username + "</a>";
$(".modal-body-apprezzamenti>p").append(html).append('.modal-body-apprezzamenti>p').append($('<br/>'));
}
$(".chiudi-popup").click(function()
{
$(".modal-body-apprezzamenti>p").html('');
});
$('#main').click(function()
{
$(".modal-body-apprezzamenti>p").html('');
});
});
});
我想为每个循环创建一个div。 我该怎么办?谢谢你的帮助。
目前,循环在哪里? – briosheje 2014-10-30 15:44:21
你想在哪里创建一个div? – 2014-10-30 15:45:21
你应该清楚你的问题。并且请添加最好的小提琴。将请求的数据作为小提琴中的静态数据 – murli2308 2014-10-30 15:47:32