Answer the question
In order to leave comments, you need to log in
Is it possible to use the each method on dynamically created elements, and how?
$(`<div class="child_container">
<img src="${item.bank_name}" alt="" height="150" width="150" class="bank_name">
<span class="result_child prcent">${item.percent}</span>
<span class="result_child price">${item.price} ֏</span>
<div class="details">
<span class="result_child">${item.varks_name}</span>
<span class="result_child">${item.expiry_date} ամիս</span>
<h6 class="clos">Փակել ▲</h6>
</div>
<h6 class="view">Մանրամասն ▼</h6>
</div>`).appendTo('#result')
})
}
})
$('.prcent').each(function(index,item){
let p = $(item).html()
p = p.split("-")
p = p[0]
$(item).html(p)
console.log(p)
})
Answer the question
In order to leave comments, you need to log in
What if:
...
$(document).each('.prcent', function(index, item) {
let p = $(item).html()
p = p.split("-")
p = p[0]
$(item).html(p)
console.log(p)
})
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question