What are the minimal/must steps needed to execute JQuery?

 Posted by Niladri.Biswas on 7/19/2012 | Category: jQuery Interview questions | Views: 1452 | Points: 40
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 

Comments or Responses

Login to post response