1
I’m trying to add a data-id
for objects that will be created dynamically, well the point is that I want to do it right when the document or my object is loaded, without the need to click etc, see the way I tried.
For example:
$(document).on('ready','.letras',function(){
$(this).attr('data-id',faixas2[k]['id_faixa']);
});
or
$(document).on('ready', function(){
$('.letras').attr('data-id',faixas2[k]['id_faixa']);
});
doesn’t happen at all.
What would be the content of faixa2?
– Laerte
The best thing would be to do this at the moment the object is created. When you say "dynamically created" you can show the code that does that?
– Sergio