Home
Jquery
Interview FAQs

FAQs of level

jQuery is a JavaScript based library that makes using the JavaScript much easier for your web based applications. The JQuery is fast, much easy to use, small in size – around 32Kb, and contains a lot of features.The jQuery is cross platform compatible, i.e. supported by many popular browsers like Chrome, Firefox, IE, Safari and others.
jQuery makes things quite simple like HTML document transversal and manipulation, handling events (like clicking on links, mouse up, mouse down etc.), animations for your applications (like slider, loader) and Asynchronous JavaScript and XML (AJAX) operations with an easy to use API.There are many other JavaScript frameworks out there like Ext JS, Dojo etc. however, the jQuery is the most widely used and popular JavaScript framework.

Variables can contain any value like text, numbers, data (such as "arrays" and "objects"), even code (in the form of "functions"). We declare a variable using a var statement:

var myName = "Reshu";

Variable names can be just about anything, as long as they do not begin with a number and do not include a hyphen.
You can define one variable per statement:

  1. var a = 1;
  2. var b = "two";
You can also define multiple variables in a single statement, by separating them with commas:
1. var a = 1,
    b = "two";

Once you have assigned a value to a variable, you can use that variable whenever you want to get access to the value you stored.

Following is the syntax of jQuery ajax get method:
$.get( url, [data], [callback function], [type] )
Where,
URL is a string specifying server to which request is sent. This is the required parameter of get jQuery.
data: Here, you will specify the data to send to the server along with HTTP request. This is an optional parameter.
callback function: Optional parameter. If the request is successful, this function will execute. It also contains the returned data from the server. The other parameters in this jQuery get callback function are:
CallbackFunction(data, status, xhr)
Where,
Data = returned data from the server.
Status = returns request status i.e. success, error, timeout, notmodified.
xhr= it contains XMLHttpRequest object. In case of Internet Explorer, it defaults to ActiveXObject otherwise XMLHttpRequest.
Type: It specifies the type of returned data from the server to the callback function. The returned data may be in these forms:  text, HTML, script, XML, JSON, jsonp.

Following is the syntax of ajax post jQuery method:

$.post( url, [data], [callback function], [type] )
Where,
URL is a string, specifying a server to which request is sent. This is a required parameter of post method.
data: post data to send to the server along with HTTP request. For example, data to be used to query user id/password from the database server. For which, the script may be written in the specified URL. This is an optional parameter of post method.
callback function: Optional parameter. If a request is successful in post method, this function will execute if given. It also contains returned data from the server. The other parameters in this call function are:
Callbackfunction(data, status, xhr)
Where,
Data = returned data from the server.
Status = returns request status i.e. success, error, timeout, notmodified.
xhr= it contains XMLHttpRequest object. In case of Internet Explorer, it defaults to ActiveXObject. Otherwise XMLHttpRequest.
dataType: It specifies the type of returned data from the server to a callback function. The returned data in post function may be in these forms:  text, HTML, script, XML, JSON, JSONP.

Events are users actions on a web page that a web page can respond to.
For example, pressing a keyboard key, bringing mouse pointer to a link, clicking a link, loading of a web page, closing a web page and other actions.
jQuery is tailor-made to respond to many useful events that a web page can get. As a user triggers those events, custom function or actions can be performed by catching those events in jQuery event handlers.
jQuery Events can be categorized into the following:

  • Keyboard events e.g. keypress, keydown, keyUp.
  • Form Events e.g. the form submit event.
  • Document events e.g. load event, resize event.

Syntax of jQuery event methods

The general syntax used for events in jQuery is:

selector.event_method();

Following are events related to mouse:
jQuery click event
e.g. $("p").click();
jQuery dblclick event
$("p").dblclick();
The mouseenter event
e.g. $("p").mouseenter ();
The mouseleave event
e.g. $("p").mouseleave ();
jQuery mousedown event
e.g. $("p").mousedown ();
jQuery mouseup event
e.g. $("p").mouseup();
jQuery hover
e.g. $("p").hover ();

List of events related to keyboard are:

jQuery keypress event

e.g. $("p").keypress();

jQuery keydown event
e.g. $("p").keydown();
jQuery keyup event
e.g. $("p").keyup();

There are list of document and windows events-

Document events
jQuery Form submit event
e.g. $("my_form").submit()
jQuery Change event
e.g. $("input").change()
jQuery Focus event
e.g. $("p").focus()
jQuery Blur event
e.g. $("input").blur
Windows events
JQuery events related to window containing a web page are:
jQuery Load event
e.g. $(selector).load(function)
jQuery Resize event
e.g. $(window).resize
jQuery Scroll event
e.g. $("div").scroll
jQuery Unload event
e.g. $(window).unload
Other events
jQuery Bind
e.g. $("p").bind
jQuery Delegate
e.g. $("div").delegate
jQuery On Event
$("p").on
jQuery Select event
$("input").select

The click event occurs when an element of HTML document is clicked. For example, clicking a button, a paragraph, a Div, a link or an image etc. As the click event occurs, an event handler can be attached to perform some action with click jQuery method.

Following is the syntax of jQuery click:
$(selector).click(function)
Where click function is optional. The function runs as the click event occurs.
Examples of how this event can be applied to different elements.
$("p").click(function)
$("div").click(function)
$("button").click(function)
Note:You can use click method by element ID or class name as well.

The double click event occurs when an element of HTML document is double-clicked.Following is the syntax of double click method:

$(selector).dblclick(function)

Where the function is optional. It runs as the double click event occurs.
e.g.
$("p").dblclick(function)
$("div").dblclick(function)
$("button").dblclick(function)

Displaying 1 of 7Next
1 2 3 4 5 6 7
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*