JQuery Programmer

  Home  Client Side Scripting  JQuery Programmer


“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”



154 JQuery Programmer Questions And Answers

121⟩ 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.

 240 views

124⟩ What is callback?

A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered.

 259 views

127⟩ What is closure?

Closures are created whenever a variable that is defined outside the current scope is accessed from within some inner scope.

 246 views

130⟩ 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.

 202 views

134⟩ What is the difference between jquery.size() and jquery.length?

jQuery .size() method returns number of element in the object. But it is not preferred to use the size() method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call.

 248 views

136⟩ How does jquery store data related to an element?

In plain java scripts the information about an element can be stored by adding a domain object model property to the element. This results in memory leak problems in certain browsers. In jquery the user does not has to worry about memory management issues.

For ex : Storing and retrieving data related to an element:

$('#myDiv').data('keyName', { foo : 'bar' });

$('#myDiv').data('keyName'); // { foo : 'bar' }

Jquery allows the user to store any kind of information on an element. The $.fn.data is used the most to store data related to an element.

For ex : Storing of relationship between elements with the use of $.fn.data :

$('#myList li').each(function()

{

var $li = $(this), $div = $li.find('div.content');

$li.data('contentDiv', $div);

});

// later, the user is not required to look for the div again;

// the data can simply be read from the list items data;

var $firstLi = $('#myList li:first');

$firstLi.data('contentDiv').html('new content');

 208 views

137⟩ 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.

 245 views

140⟩ Is it possible to get value of multiple CSS properties in single statement?

Well, before jQuery 1.9 release it was not possible but one of the new feature of jQuery 1.9 was .css() multi-property getter.

var propCollection = $("#dvBox").css([ "width", "height", "backgroundColor" ]);

In this case, the propCollection will be an array and it will look something like this.

{

width: "100px",

height: "200px",

backgroundColor: "#FF00FF"

}

 243 views