Practical jQuery Questions and Answers

ADMEC Multimedia > Web Design > Practical jQuery Questions and Answers

jQuery is a widely used JavaScript library. It helps in simplifying HTML DOM tree traversal as well as manipulation. Its syntax is capable of navigating through a DOC, elements of DOM, creation of animations, handling events as well as developing of Ajax related applications. It is of great use in building dynamic webpages.

Have you completed your jQuery course from and institute or by self-study and planning for an interview to start your career in a good UI development or website development company? If yes then all the following given questions will help you in cracking out the jQuery interview phase easily.

Q1. What is jQuery and how it is different from JavaScript?

Answer: jQuery is a JavaScript’s framework as all we know. It’s purpose to reduce the development time and lines of code to improve the productivity. If you are working with jQuery, you don’t need to reinvent the wheel so it provides reusable code structure and rapid development environment.

Q2. Why do we use jQuery instead JavaScript?

As I above said jQuery helps in creating applications in less time than the JavaScript. jQuery has readymade APIs to be used by developers to achieve the same that you get in JavaScript after so many lines of codes.

Q3. How JavaScript and jQuery are different?

I think the question would be something like this ‘How knowledge of JavaScript and jQuery helps developers ?’. As I said above that jQuery is a framework of JavaScript means jQuery is developed on top of JavaScript. So, as strong you are in JavaScript as good you are in jQuery.

Q4. Is jQuery a replacement of Java Script?

No, seriously not. Its just a framework of JavaScript. Read question no. 3 and 2.

Q5. Is jQuery for client scripting or server scripting?

Strictly jQuery is a client side scripting. It is very cool to create animations for web pages in maintainable manner.

Q6. Is jQuery a W3C standard? If no then why and if yes then what are the issues preventing jQuery in becoming a W3C standard?

No, it’s not because it is a library akin tons of others of JavaScript. jQuery uses many not standard methods and properties such as innerHTML to accomplish the tasks. We know that JavaScript can do everything that jQuery does so there is no point in making it a standard by W3C.

Q7. Why advanced knowledge of JavaScript helps to start with jQuery?

Because a framework suggest you so many APIs to use and create something in minutes or seconds. So you wouldn’t like to ride horse without learning riding, when you learn JavaScript then you learn the basics of programmings, logic making, and see DOM traversing in-depth. And this sense of programming helps you in making html to DHMTL using jQuery. Wanna to work as a programmer then you need to learn JavaScript.

Q8. Which is the starting point of code execution in jQuery?

$(document).ready() function takes this initiative and it fires functions inside it when DOM is ready.

Q9. What does dollar sign ($) means in jQuery?

$ is a function that called jQuery and it helps in managing all the functionality in the jQuery library.

$('div#id') === jQuery('div#id');

Q10. Should we have multiple document.ready() function on the same page?

Technically not !! It’s better to create an organized code structure by using one document.ready() and either put all the functions in it or call them as per the requirements.

Q11. Can we use our own specific character in the place of $?

Yes you can use surely. Please see the below given code.

var j = jQuery.noConflict();

Now j can be used in place of $ sign in all over the code.

Q12. Is it possible to use other client side libraries like MooTools, Prototype along with jQuery?

The very straightforward answer is ‘YES’. We can use it if we follow some very basic instructions. Always avoid $ sign in jQuery if using other libraries too or using with some frameworks that use other JavaScript frameworks to avoid conflict in them. See Question 11 for more detail, please.

Q13. What is jQuery.noConflict?

Read question number 11 and 12 please.

Q14. Is there any difference between onload event of JavaScript and document.ready() API in jQuery?

Yes, onload or load event fires once all the contents are loaded of the page including images, scripts, media elements etc and in contrast jQuery.ready() or $.ready() event fires asap browser ensures for web page’s DOM is ready meaning $.ready() gets fires before the window.onload or $.load. You can use onload event when you are creating preloader but $.ready() can’t be used there and $.ready() is useful for interactive animations in the page.

Q15. What is the difference between .js and .min.js?

First one is uncompressed while second one is compressed JavaScript file. We should always use compressed JavaScript files in our website to make it run fast.

Q16. Why there are two different versions of jQuery library 1.x and 2.x?

jQuery 1.x is good when you want to create applications for IE 6, 7, and 8 and obviously jQuery 2.x is good for IE 8+.

Q17. What is a CDN?

CDN or Content Delivery Network is a network that helps in improving website’s performance at the production. Because there is a limit to resolve HTTP Requests on servers coming from websites so CDN is a great way to improve it by sharing content used in a website.

Q18. Which are the popular jQuery CDN and how to load from them?

Followings are the few popular jQuery CDN:

Just copy any of the above url and put in src attribute of this tag <script type=”text/javascript” src=”paste here”></script>

Q19. How to load jQuery locally when CDN fails?

As CDN is the best way to link a library but there might be a chance when due to heavy load a CDN server become unresponsive. So go with the following procedure always.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined'}
{
     document.write(unescape("%3Cscript src='Scripts/jquery.1.5.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>

Q 20) What do you understand by the term Method chaining in jquery?

When we want various methods to be executed in a sequence in a single code statement, then this is called method chaining.

For instance :

Code without chaining :

$( "button#play-video" ).on( "click", playVideo );
$( "button#play-video " ).css( "background-color", "red" );
$( "button#play-video " ).show();

Code with chaining :

$( "button#play-video" ).on( "click", playVideo )
                        .css( "background-color", "red" )
                        .show();

Q 21) Explain the difference between jquery.ajax() and jquery.get()?

Jquery.get() –  To build an ajax request for retrieval of information we use jquery.ajax. It also provides other requests such as jquery.post(), jquery.getJSON() etc. In this jquery.ajax is use under the hood.

Jquery.ajax() – It makes the use of different ajax request methods easy. We can easily customize the requests, we can customize how long do we want the user to wait for the response, failure handling, blocking or non-blocking of a request.

Q 22) What do you understand by .detach() as well as .remove()?

Ans) It’s very simple!!! Both are the same except a slight difference. .detach has all the values that are there even after removal. Whereas, this X-factor is not there in .remove(). That is why .detach is used when we want to retain the values that we deleted.

Q 23) Explain the following :
$(“div#name, div.name, ol#items > [firstname$=’name’]”)

Here some <div> element is used along with id i.e. name, along with all the div elements that have a class named as name and all elements that are children of the <ol id=”items> element where the attribute first name ends with the string “name”.

Q 24) Explain the difference between the two :
JQuery.attr() and JQuery.pop()

Jquery.attr() is generally used to get the value attribute for any first element that there is the set of elements that are matched.

Jquery .pop() is the one that is used to get the value of a property for the first element that is there in the set of matched elements.

Q 25) Name the different methods that you can use in jquery to provide the effects?

Here are the methods that are provided by jquery that are useful for providing effects on the webpage.

Following are the methods :

  • FadeIn()
  • Toggle()
  • Show()
  • Hide()
  • FadeOut

A similar blog you may want to read – 20 Interview Questions and Answers of JavaScript to Crack Interview in 2019

Want to know the answers to these questions in detail then I would recommend you visit our institute or call for course inquiry at 9811-8181-22. Our experts will help you surely.

Thanks

Leave a Reply

Related Posts

Copy link
Powered by Social Snap