To attach a click event to an element, click()
method can be used that fires when the element is clicked.
<script>
$("#btnClick").click(function () {
alert("click event called");
})
</script>
Above code snippet first find html element whose id is "btnClick" and attach "click" event. When this element is clicked, a function fires that shows "click event called" message in the JavaScript alert box.
Views: 5572 | Post Order: 62