A
A
Anon33632020-05-05 14:28:32
JavaScript
Anon3363, 2020-05-05 14:28:32

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} &#1423;</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

1 answer(s)
M
mahmudchon, 2020-05-05
@mahmudchon

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 question

Ask a Question

731 491 924 answers to any question