With rich internet applications (RIA) being deployed everywhere including enterprises, the related UI frameworks to build these applications are also in demand. Every framework provides something which is fresh in the market.
These UI frameworks are javascript based, have support for Ajax, have cross browser support and are extensible. So when you are being screened for a requirement in the organization, the interviewer will try to judge you on various aspects of an application. Here in this article, I am listing few jQuery Interview Questions which are helpful to all developers and UI developers in particular.
1) What do you need to do in order to use jQuery in your project?
Ans: We need to import the jQuery minified js and css files
2) What is the difference between normal and minimal version of .js files that are shipped with jQuery bundle?
Ans: The minified version is useful in production system because it saves the bandwidth and decreases page loading speed.
3) Can one download and change the jQuery base code and use it? Did you every feel like changing the code base for something that was missing in the bundle? Under what scenarios will you consider modifying the jQuery code base?
Ans: This should ideally never be required and we shall post the issue to jQuery library to the developer community.
4) Which version of jQuery have you worked on. What steps will you take to migrate your web application to the latest version of jQuery?
Ans: There are different versions for jQuery Mobile and jQuery normal libraries and discuss the version you have been using.
5) What all features of jQuery have you used in your web projects?
Ans: jQuery offers a lot of features like Accordian, Sliding menu, File upload etc.
6) Would you prefer using a feature available in jQuery than writing the same functionality using custom javascript and CSS?
Ans: It is better to use the same feature using jQuery than writing custom css and js.
7) What all browser related issues you have faced with jQuery?
Ans: Browser compatibility of jQuery plugins is an issue and needs lot of time and effort to fix.
8 ) What is the difference between javascript’s onload function invoked from HTML body tag like
and jQuery’s ready function?
Ans: We can have multiple onload handlers in jQuery but not with body tag.
9) On what parameters will you judge a jQuery plugin before using it in your application?
Ans:
1) Browser compatibility.
2) Performance.
3) Ease of use.
10) What all techniques have you been using in order to increase the performance of a web application developed using jQuery?
Ans: Try not add too many event handlers on load event. Use proper element selectors.
11) Given the option to decide on a Javascript framework for a JEE based web application, what other frameworks will you consider before making a choice?
Ans: There are many other food javascript frameworks including prototype, dojo and YUI.
Note: You may also want to browse through our dojo tutorial series.
12) What all jQuery plugins have you used? Explain them?
13) Can you write the code to send an Ajax request to a JSP page?
Ans: One can use $.POST() and $.GET() to issue Ajax requests in web applications.
14) Have you used overlay effect of jQuery? What configuration settings are available for creating the overlay effect?
15) Which jQuery editor do you use?
Ans: While there could be multiple plugins for IDE that add jQuery support but you shouldn’t fail to mention the big names like Aptana Studio IDE and less known jsdt-jquery.
16) What are the ways by which I can include jQuery in my web pages? Which one is the best?
Ans: We can download a out of the box development and production versions from jQuery website and use it in our applications. There is also an option to create a custom build where we can leave out unnecessary widgets and hence reduce the size of our JS file. If the web application is going to be hosted on the internet then we can refer to Content Delivery Networks (CDN) like Google code to make the browser download the script from Google servers and use it.
17) What is a selector?How many type of selectors are available?
Ans: The selectors are used to select a single or group of elements before performing an operation on them. The following are the selectors available in jQuery:
1) Select elements by tag name — $(div)
2) Select elements by ID — $(#xyzid”)
3) Select elements by class — $(“.xyzclass”)
Out of the above, the most efficient is selecting element by ID as it translates to native Javascript call document.getElementById(“xyzid”);
18) How would you animate elements in jQuery?
Ans: There is animate function available in jQuery API which can be used to perform animations as shown in the following code example:
The syntax of animate function is: $(selector).animate({params}, [duration], [easing], [callback])
param defines the CSS properties on which you want to apply the animation.
duration specify how long the animation will run. It can be one of following
values : whether the animattion is slow, fast or normal
easing : is the string which specify the function for the transition.
callback is the function which we want to run once the animation effect is complete.
Example:
$(‘# clickToAnimate’).click(function() {
$(‘#book’).animate({
opacity: 0.30,
left: ‘+=20′,
height: ‘toggle’
}, 3000, function() {
// run after the animation complete.
});
});
19) How would You disable or enable a form element?
Ans: Elements can be disabled by using the following code samples:
$(‘#sampleid’).attr(‘disabled’, true);
$(“#sampleid”).attr(‘disabled’, ‘disabled’);
20) How would you check or uncheck a checkbox input or radio button?
Ans: Elements can be checked/unchecked by using the following code samples:
check