To be precise:
for(var i=0;i<10;i++){
$('.mov_c').append('<div class="move_1" id="vid_c_'+i+'"></div>');
$('#vid_c_'+i).append('<div class="move_2"></div>');
$(".move_2").load("cntent.html", function (){
$('#theelement').attr("id", "id_"+i);
});
}
cntent.html:
<div class="theelement" id="theelement"></div>
New Udate:
for(var i=1;i<10;i++){
$(".move_2").load("cntent.html", (function (x){
$('.#theelement').attr("id", "id_"+x);
console.log("Index: "+x); // output values are from 1 to 10
})(i));
}
}
Didn't worked
Basically I want each time cntent.html
is called my theelement
just created id to change to i
value. The problem with the way i'm doing it is that it changes the whole elements id to just id_10
, But I want theelement
s ID to change based on for
loop value, saying: element one with id of id_1
, element two with id of id_2
and so on.
Regards