jQuery Interview Questions

Recommended by 0 users

JQuery Interview Questions

jQuery Basics

Q. What language is jQuery written in?

It is written in JavaScript.

Q. How is jQuery installed?

Downloading the latest distribution from jQuery.com, then placing it on the webserver where it can be accessed during HTML page loads by the browser.

Q. Where does jQuery code run?

The jQuery code runs in the client browser.

Q. What is the purpose of the jQuery library?

The purpose of jQuery library is to simplify document traversing, event handling animation and AJAX interaction and more importantly to do these things in a cross-browser friendly way.

Q. Illustrate the code needed to include the jQuery library in an HTML file.

<script src=”jQuery.js”></script>

Q. What are the prerequisites for using jQuery? What are the minimum browsers that support it?

Firefox 3.6+, IE 6+, Safari 3+, Opera all, Chrome all

Q. How much does jQuery cost?

Trick Question: It’s free.

Q. Under what licenses can one use jQuery

MIT and GPL licenses are both available, and either one can be used.

Q. Can jQuery be used in commercial projects?

Yes, as long as the copyright header is intact.

Q. What are some typical uses for the jQuery library?

Typical uses for the iQuery library are Animation, AJAX, Active content without using Flash.

Q. What data types does the jQuery library add to JavaScript?

Selectors and Events

Q. What is the current version of jQuery?

1.6 (This may be larger, depending on when the question is used, but as of this writing, jQuery is at revision 1.6)

Q. Illustrate selecting an element using its ID.

${‘#myID’} The # is the key here.

Q. Illustrate selecting a HTML element using its class.

${‘.myClass’} The leading .(dot) is important.

Q. Illustrate assigning a selected element to a JavaScript variable

var myElement = ${‘#myID’}

Q. Illustrate determining if an element exists.

if ( ${‘#myID’}.length ) The length property will be non-zero if the element exists.

Q. Illustrate determining if an element is visible or hidden.

${‘#myID’}.is(‘:visible’) or is(‘:hidden’) as needed.

Q. Why is it important to bind events to new elements if they’re created after the initial JQuery call?

Elements created after the initial calls are not bound to any events. Events won’t work on those elements unless they are explicitly bound.

Q. What is the ready event?

It is an event created by jQuery that waits until the document is ready to be manipulated. This can be used to run code before the page images are loaded.

Q. How is the default behavior of an elements event overridden?

It is done using the .preventDefault method in the event handler.

jQuery Core

Q. How is the jQuery’s control of the $ variable released?

Using the jQuery.noConflict() method. This is new in 1.6

Q. How can callback functions be executed?

Using the jQuery.when() method and a deferred object.

Q. What is a deferred object?

It is an object used to represent asynchronous events. Usually used with jQuery.when()

Q. How can the ready event be delayed?

Using jQuery.holdReady()

Q. When would it be necessary to hold the ready event?

When waiting for a custom plugin to load, or for other technologies to be ready before executing jQuery code.

Q. What is jQuery.sub()?

It is a means by which a new copy of jQuery can be instantiated. It is useful when a programmer wants to override properties or methods of jQuery without destroying the original behavior.

Q. What are some parameters to jQuery()?

A string which contains a CSS selector, DOM elements, elementArrays, jQuery objects.

Q. When is jQuery.deferred() used?

It is used to register one or more callbacks, to be processed asynchronously.

Q. Is it possible to remove all jQuery variables from the global scope including jQuery itself?

Yes. Using jQuery.noConflict(true)

Q. How is jQuery.deferred() related to AJAX processing?

It allows code to be executed conditionally, based on the outcome of other asynchronous code.

Jquery and AJAX

Q. What does AJAX stand for? How is it used?

Asynchronous JavaScript And XML. It’s used for handling web interaction interactively, beyond the traditional form submission / page reload paradigm.

Q. What is JSON? What is it used for?

JSON stands for JavaScript Object Notation. It is used as a data interchange format, largely replacing XML in interactive JavaScript-based web applications.

Q. How is JSON data loaded from the server via an HTTP GET request?

Using jQuery.getJSON()

Q. How are default values for future Ajax queries set?

Using jQuery.ajaxSetup()

Q. What are some global Ajax event handlers?

.ajaxError(), .ajaxComplete(), .ajaxSend(), ajaxSuccess(), .ajaxStart(), .ajaxStop()

Q. What does the .load() method do?

It queries the server, and places the returned values into a matched HTML element.

Q. What does .serialize() do?

It encodes a set of form elements into a string.

Q. What method is used to perform an Ajax request?

The jQuery.ajax() method along with either XML or a JSON object to be transferred.

Q. How is a handler registered to be called when Ajax requests have completed?

Using the .ajaxStop() handler.

Q. How is an error handler attached to an Ajax request?

.ajaxError() is used, and will only be called if an Ajax request completes with errors.

jquery – Selectors

Q. How are all elements selected?

Using the * wildcard (“*”)

Q. How can all attributes which contain a particular word be selected?

Using the contains word selector ~= For example [myName~=”wordOfInterest”]

Q. How can all attributes which end in the suffix ‘ing’ be selected?

Using the ends with selector $= For example [myName$=”ing”]

Q. What selector is used to select all activated checkboxes?

The :checked selector. Alternatively, the :checkbox selector will select all checkboxes, checked or not.

Q. What does the :input selector select?

All input, text area, select and button elements.

Q. What does the :lt(index) selector select?

It selects all elements with an index less than the index within the currently matched set. It is a less-than filter.

Q. How are all elements that are not visible selected?

Using the :hidden Selector. Alternatively, :visible can be used in conjunction with the :not filter.

Q. What is the ^= selector?

It is the “starts with” selector, used to select attributes that begin with a certain string.

Q. What is the |= selector?

It is the “Contains Prefix” selector, It returns all attributes that either equal to the string, or are prefixed with the string followed by a hyphen.

0 Responses on jQuery Interview Questions"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.