0
I have the following code, which is added dynamically:
var m = 0;
$$("#add_medicamento").click(function(){
m++;
var medicamento = $$("#select_medicamento").val();
var qnt = $$("#quantidade").val();
$$("#lista_medicamentos").append('<li class="swipeout">'+
' <div class="swipeout-content item-content">'+
' <div class="item-inner">'+
' <div class="item-title-'+m+'">'+medicamento+'</div>'+
' <div class="item-after-'+m+'">'+qnt+'</div>'+
' </div>'+
' </div>'+
' <div class="swipeout-actions-right">'+
' <!-- Add this button and item will be deleted automatically -->'+
' <a href="#" class="swipeout-delete">Apagar</a>'+
' </div>'+
'</li>');
})
And I’m trying to get the name of the drug (within the div class="item-title" which is dynamic), and the amount of drugs inserted (within the div class="item-after" which is also dynamic).
I tried it this way, but without success:
var medicamentos = $$("#lista_medicamentos .item-inner");
medicamentos.each(function(idx, li){
var teste = $(li);
alert(teste);
})
How can I fix this?
Some warning is issued?
– Woss
Yes!
[Object Object]
, and if I switch to the.log console, the following appears::Object [ <div.item-inner> ]
– Guilherme Lirio
So it’s working. In place of
alert
try to putconsole.log(teste.find(".item-title-*").html())
– Woss
Opa, gave right @Andersoncarloswoss . If you want to post as an answer, confirm! Thanks!
– Guilherme Lirio