Answer: 1.Wait for the DOM of the page to be ready.
2.Finds the appropriate HTML elements that needs to be acted on by using selector.
3.Add event handlers.
e.g.
//Step 1: Wait for the DOM of the page to be ready.
$(document).ready(function ()
{
//Step 2: Finds the appropriate HTML elements that needs to be acted on by using selector
var btnObject = $('#btnSayHello');
//Step 3: Add event handlers (Here click events)
btnObject.click(function ()
{
alert("Hello World...My First JQuery Program");
});
});
Asked In: Many Interviews |
Alert Moderator