What does on() in JavaScript do?

The on() method attaches one or more event handlers for the selected elements and child elements.

Read more about jQuery on() Method

As per your code $(document).on('click','#add'), I guess it’s creating a delegated event.

It will directly fired on #add id element

Leave a Comment