0

What will be best solution / practice to get dynamically added elements with Javascript? For example I'm creating To Do app and then I add new task I get respond from backend and I append new task code to front end. But if my recently added task have so buttons I can't click them.

I could use <div onClick=myFunction()></div> but as far as I know it's not the best way / practice. Also I know that in jquery you can solve this problem with this method: $('.container').on('click', 'element', function()). Does vanilla Js has something like this? Because I don't want to use jQuery. Or I should after every ajax request call function which select all buttons ?

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

0 Answers0