jQuery Quiz Questions 1-10

Share this article

There will be an interactive jQuery quiz released soon in the members section where you can win prizes. In the meantime, here are a few jQuery questions
which didn’t make the quiz but I thought it would be nice to share them with you, might be useful for some of you trying to learn jQuery or creating a quiz of your own. Hey, you may even learn something you didn’t know about jQuery.  There are quite a few questions, here are questions 1-10. Enjoy!

Question 1

Which of the following elements can you attach jQuery events to? Answers
  • object
  • embed
  • applet
  • None of the above
Correct Answer None of the above You cannot attach events to object, embed, applet elements. jQuery’s event system requires that a DOM element allows attaching data via a property on the element, so that events can be tracked and delivered.  

Question 2

Is the following statement true or false? jQuery’s event system requires that a DOM element allows attaching data via a property on the element, so that events can be tracked and delivered. Answers
  • true
  • false
Correct Answer true  

Question 3

Is the following statement true or false? jQuery defines focusin and focusout events which are a cross-browser of the focus and blur events. Answers
  • true
  • false
Correct Answer true The focus and blur events are specified by the W3C to not bubble, but jQuery defines cross-browser focusin andfocusout events that do bubble. When focus and blur are used to attach delegated event handlers, jQuery maps the names and delivers them as focusin and focusout respectively. For consistency and clarity, use the bubbling event type names.  

Question 4

Which code is faster? Answers
  • $(‘#test1, .test2, .test3, .test4’);
  • $(‘#test1’).add(‘.test2’).add(‘.test3’).add(‘.test4’);
Correct Answer $(‘#test1, .test2, .test3, .test4’); //faster jsperf: http://jsperf.com/multiple-jquery-id-selects/2 API: http://api.jquery.com/add/  

Question 5

$.grep(array1, function1); The above statement ___ the elements of array1 array which satisfy function1 function. Answers
  • sorts
  • updates
  • removes
  • filters
Correct Answer filters API: http://api.jquery.com/jQuery.grep/  

Question 6

Consider the following code snippet:
  • Items 1
  • Items 2
  • Items 3
Which of the following code snippets returns the same result as $(‘#id1 li’).not($(‘#li2’));? Answers
  • $(‘#li2’).siblings();
  • $(‘#id2’).siblings(‘#li2’);
  • $(‘#li2’).children();
  • $(‘#id2’).children(‘#li2’);
Correct Answer $(‘#li2’).siblings(); see answer in action: https://jsfiddle.net/jquery4u/pHtbq/  

Question 7

The hide() function hides an element by ____. Answers
  • setting “display” inline style attribute of that element to “none”.
  • setting “visibility” inline style attribute of that element to “hidden”.
  • setting the horizontal attribute of that element to “-100px” off visible screen.
  • setting the vertical attribute of that element to “-100px” off visible screen.
Correct Answer setting “display” inline style attribute of that element to “none”. API: http://api.jquery.com/hide/  

Question 8

Which of the following is the correct way to create a div element with a link text “Hello” with jQuery? Answers
  • $(“#idName”).create(“div”).text(“Hello“);
  • $(“#idName”).create(“div”).html(“Hello“);
  • $(“idName”).css(“div”).html(“Hello“);
  • $(“#idName”).append(“Hello“);
Correct Answer $(“#idName”).append(“Hello“);  

Question 9

Consider the following code snippet? function function1() { alert(arguments.length()); } Which of the following is true when you run function1();? Answers
  • An error occurs because arguments variable is undefined.
  • An error occurs because you call function1 with no arguments.
  • The alert box displays “undefined”.
  • The alert box displays 0.
Correct Answer An error occurs because you call function1 with no arguments. Uncaught TypeError: Property ‘length’ of object #  

Question 10

$.extend(false, object0, object1, object2); What does the code above do? Answers
  • Extends the object0 by merging object1 and object2 with object0.
  • Extends the object1 by merging object0 and object2 with object1.
  • Extends the object2 by merging object0 and object1 with object2.
  • The statement is invalid because its arguments are invalid.
Correct Answer Extends the object0 by merging object1 and object2 with object0. API: http://api.jquery.com/jQuery.extend/

Frequently Asked Questions (FAQs) about jQuery Quiz

What is the purpose of jQuery?

jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, and animation much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

How can I start learning jQuery?

The best way to start learning jQuery is by understanding the basics of HTML, CSS, and JavaScript. Once you have a good grasp of these, you can start learning jQuery. There are many online resources available, including tutorials, videos, and blogs. You can also practice your skills by taking quizzes like the one on our website.

What are some common jQuery functions?

jQuery includes a wide range of functions. Some of the most commonly used ones include .click(), .hide(), .show(), .toggle(), .slideUp(), .slideDown(), .animate(), .fadeIn(), .fadeOut(), .val(), .text(), .html(), and .css().

How can I use jQuery in my HTML file?

To use jQuery in your HTML file, you first need to include the jQuery library. This can be done by downloading the jQuery file from the jQuery website and including it in your HTML file using the <script> tag. Alternatively, you can include it directly from a Content Delivery Network (CDN).

What is the difference between jQuery and JavaScript?

JavaScript is a programming language that is used to make web pages interactive. On the other hand, jQuery is a library built with JavaScript to simplify the client-side scripting of HTML. It provides a simpler and more concise syntax, which makes it easier to use than raw JavaScript.

How can I handle events in jQuery?

jQuery provides several methods to handle events such as click, double click, mouseenter, mouseleave, hover, focus, blur, etc. These methods can be used to attach event handlers to elements.

What is the use of AJAX in jQuery?

AJAX stands for Asynchronous JavaScript and XML. It is used in jQuery to load data from the server without refreshing the whole page. jQuery provides several AJAX methods to develop fast and interactive web applications.

How can I create custom events in jQuery?

jQuery allows you to create custom events using the .trigger() method. This method can be used to trigger both built-in and custom events on the selected elements.

What are the advantages of using jQuery?

jQuery offers several advantages. It simplifies the process of traversal of HTML documents, provides a simple and powerful syntax, supports AJAX, provides a lot of built-in effects and animations, and is highly extensible through its plugin architecture.

How can I improve my jQuery skills?

The best way to improve your jQuery skills is by practicing. You can start by taking quizzes like the one on our website. You can also work on small projects, contribute to open-source projects, or solve problems on coding platforms.

Sam DeeringSam Deering
View Author

Sam Deering has 15+ years of programming and website development experience. He was a website consultant at Console, ABC News, Flight Centre, Sapient Nitro, and the QLD Government and runs a tech blog with over 1 million views per month. Currently, Sam is the Founder of Crypto News, Australia.

jQuery
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week