This blog explain us, how to work .click() and .on('click') event in jquery .on('click') is different from .click(), there it has the capacity to create delegated event handlers by passing a selector parameter, while .click() does not. When .on('click') is called without a selector parameter, it behaves same as .click(). In case you want event delegation, use .on('click').
Now, we will define the code structure
HTML
$(document).ready(function(){ $('input[type="button"]').click(function(){ var button = ''; $('.btn').append(button); }); }); $(".btn").on("click", "#button2", function(){ alert("10") });
Thanks
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vinay Tiwari
Vinay is a bright UI developer, having knowledge of HTML, CSS, Bootstrap, Jquery and AngularJs. His hobbies are interacting with people, listening music etc.