I have this code:
for(var i = 0; i < subjects.length; i++){
$('#container').append('<div class="content"><span class="context-text" data-item="' + i '">' + subject[i].title + '</span></div>');
}
It is not working. This does work:
for(var i = 0; i < subjects.length; i++){
$('#container').append('<div class="content"><span class="context-text" data-item="1">' + subject[i].title + '</span></div>');
}
Can anybody help? I am missing something and I don't see what it is.
Missed + after i
Change this line
to