Wednesday, June 18, 2014

JQuery - Detect a button click

The following example shows how to detect a button click.
With JQuery detect when the document is ready
Load for the button by it's id
Call the Click event of the button
Make an empty function with the code to be executed when the click event happens
 

// Java Script Function
$(document).ready(function () {
    $('#btn').click(function () {
        alert("The button was clicked.");
    });
});


    Click this button:

    

No comments:

Post a Comment