A
A
Anon33632020-05-04 23:40:42
JavaScript
Anon3363, 2020-05-04 23:40:42

Why doesn't the click on the dynamically created button react?

if(newresults && newresults.length > 0 ){
                    $(".child_container").remove();
                    newresults.forEach((item,index) =>{

                        $(`<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')
                        

                    })
                }
            })

            // $('.view').click(function(){
            //     console.log(true)
            //     $(this).parent().find($('.details')).slideDown(1000)
            //     $(this).fadeOut(300)
            // })

            // $('.clos').click(function(){
            //     $(this).parent().slideUp(1000)
            //     $(this).parents().find(".view").fadeIn(300)
            // })

              $('.view').on("click" , function(){
                console.log(true)
                $(this).parent().find($('.details')).slideDown(1000)
                $(this).fadeOut(300)
            })

            $('.clos').on("click" , function(){
                $(this).parent().slideUp(1000)
                $(this).parents().find(".view").fadeIn(300)
            })

        });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2020-05-04
@Anon3363

It has already happened more than once Why does remove not work?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question