Fresh JQuery Programmer Interview Preparation Guide
Download PDF

JQuery Programmer Frequently Asked Questions in various JQuery Developer job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting

201 JQuery Programmer Questions and Answers:

Table of Contents:

Fresh  JQuery Programmer Job Interview Questions and Answers
Fresh JQuery Programmer Job Interview Questions and Answers

1 :: Create a plugin that would add and remove a class on hover?

The plugin can be considered to be simply a new method that can be used by a user to extend the prototype object of a jquery. A plugin performs some actions on a collection of elements. Each method that comes with the jquery core can be considered to be a plugin.

The code for creating a plugin that would add and remove a class on hover would be as follows:
(function($)
{
$.fn.hoverClass = function(c)
{
return this.hover(
function() { $(this).toggleClass(c); }
);
};
})(jQuery);

// using the plugin
$('li').hoverClass('hover');

2 :: Explain the common methods of sending a request to a server?

The two most common methods of sending a request to a server are :

1. GET method : The get method is mostly used for non destructive operations. These operations get data from the server and does not change the data on it. A good example of the application of the search query to a server. In most of the cases GET will send all of the data to be sent in the form of a query string.
2. POST method : The POST method is primarily used for destructive operations. These operations can change the data on a server. A good example is a user saving an entry on a site will get the POST request. These requests are not cached by the browser. A query can be a part of a url but any data that is to be sent is done separately as post data.

3 :: How to get the height of an element using jQuery?

The height( ) method gets the current computed, pixel, height of the first matched element.

4 :: How to remove set of matched elements using jQuery?

The remove( expr ) method removes all matched elements from the DOM.

5 :: What are jQuery Selectors? Give some examples?

1. jQuery Selectors are used to select one or a group of HTML elements from your web page.
2. jQuery support all the CSS selectors as well as many additional custom selectors.
3. jQuery selectors always start with dollar sign and parentheses: $().
4. There are three building blocks to select the elements in a web document.

1) Select elements by tag name
Example : $(div)
It will select all the div elements in the document.

2) Select elements by ID
Example : $("#xyzid")
It will select single element that has an ID of xyzid.

3) Select elements by class
Example : $(".xyzclass")
It will select all the elements having class xyzclass.

6 :: How to set the style property of an element using jQuery?

The css( name, value ) method sets a single style property to a value on all matched elements.

7 :: Which is the starting point of code execution in jQuery?

The starting point of jQuery code execution is $(document).ready() function which is executed when DOM is loaded.

8 :: How to get the style property of an element using jQuery?

The css( name ) method returns a style property on the first matched element.

9 :: What is the difference between .js and .min.js?

jQuery library comes in 2 different versions Development and Production/Deployment. The deployment version is also known as minified version. So .min.js is basically the minified version of jQuery library file. Both the files are same as far as functionality is concerned. but .min.js is quite small in size so it loads quickly and saves bandwidth

10 :: How to get the direct parent of an element using jQuery?

The parent( [selector] ) method gets the direct parent of an element. If called on a set of elements, parent returns a set of their unique direct parent elements.

11 :: What are the slow selectors in jQuery?

class selectors are the slow compare to ID and element.

12 :: How to add the previous selection to the current selection using jQuery?

The andSelf( ) method adds the previous selection to the current selection.

13 :: How to check data type of any variable in jQuery?

Using $.type(Object) which returns the built-in JavaScript type for the object.

14 :: How to set the html contents of an element using jQuery?

The html( val ) method sets the html contents of every matched element.

15 :: How to select element having a particular class (".selected")?

$('.selected'). This selector is known as class selector. We need to prefix the class name with "." (dot).

16 :: How to prevents the browser from executing the default action using jQuery?

The preventDefault() method of Event object prevents the browser from executing the default action.

17 :: What are deferred and promise object in jQuery?

Deferred and promise are part of jQuery since version 1.5 and they help in handling asynchronous functions like Ajax.

18 :: Is jQuery replacement of Java Script?

No. jQuery is not a replacement of JavaScript. jQuery is a different library which is written on top of JavaScript. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

19 :: What is finish method in jQuery?

The .finish() method stops all queued animations and places the element(s) in their final state. This method was introduced in jQuery 1.9.

20 :: What is the difference between eq() and get() methods in jQuery?

eq() returns the element as a jQuery object. This method constructs a new jQuery object from one element within that set and returns it. That means that you can use jQuery functions on it.

get() return a DOM element. The method retrieve the DOM elements matched by the jQuery object. But as it is a DOM element and it is not a jQuery-wrapped object. So jQuery functions can't be used.

21 :: What are the fastest selectors in jQuery?

ID and element selectors are the fastest selectors in jQuery.

22 :: How to stop the rest of the event handlers from being executed in jQuery?

The stopImmediatePropagation() method of Event object stops the rest of the handlers from being executed.

24 :: What is the difference between event.PreventDefault and "return false"?

e.preventDefault() will prevent the default event from occurring, e.stopPropagation() will prevent the event from bubbling up and return false will do both.

25 :: What is jQuery plugin and what is the advantage of using plugin?

A plug-in is piece of code written in a standard JavaScript file. These files provide useful jQuery methods which can be used along with jQuery library methods. jQuery plugins are quite useful as its piece of code which is already written by someone and re-usable, which saves your development time.
JQuery Programmer Interview Questions and Answers
201 JQuery Programmer Interview Questions and Answers