Answer the question
In order to leave comments, you need to log in
Events not working for dynamically created elements?
When a button is clicked, an element should be created and it would seem that everything works, but the events associated with the classes of this element do not work
$('.add-newPost-bth').on('click', function(){
$(`<div class="newPost">
<div class="form-new-post">
<form class="field-form-new-post">
</form>
</div>
<script>
autosize($('.textaria-new-post'));
</script>
</div>`).insertAfter('.newPost')
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question