我需要尋求幫助。 擁有此代碼:在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