To handle a click event on a dynamically created element in jQuery, you should use the .on() method with event delegation. This approach allows you to attach an event listener to a parent element that exists when the page loads and delegate the event handling to a specified child element, even if it is added later.
Here’s the syntax:
$(parentSelector).on("click", childSelector, function() {
// Event handler code
});