S
S
Sasha Brahms2015-10-28 22:45:44
JavaScript
Sasha Brahms, 2015-10-28 22:45:44

How to properly attach an event to the created element?

created/added element div class="activity /div
how to attach Event ?
elem.addEventLis... to it every time it is created? what
if I just added it via innerHTML += div class="activity" ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
littleguga, 2015-10-28
@Dlike

1. If using jquery:
For dynamically created elements. Where click is an event, selector is a selector, handler is a function.
2. If without jquery:
you can do this , but this option is not very good. It will be better through addEventListener.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question