How to attach a click event to an element in jQuery – .click()

To attach a click event to an element, click() method can be used that fires when the element is clicked.

$("#btnClick").click(function () {
alert("click event called");
});

Above code will execute when user clicks the button “btnClick”.

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.