Jquery on() event function
The Jquery official documentation suggests using “on of function” to create events. It has a lot of advantages. One of the advantages is getting dynamic elements easily.
Drupal Ajax is very powerful for the developer. But most of the noob of developer are scared it. If you understand how it works, you will love it forever. And I prefer using “Drupal behavior” to fix ajax problems. Hope it can help you.