jQuery MCQs

jQuery MCQs

These jQuery multiple-choice questions and their answers will help you strengthen your grip on the subject of jQuery. You can prepare for an upcoming exam or job interview with these jQuery MCQs.
So scroll down and start answering.

1: How is jQuery licensed?

A.   Secret

B.   Private

C.   Open source

D.   Proprietary

2: What does this code do: $('#id1').animate({width:'250px'}, 'slow').animate({height:'250px'}, 'fast');

A.   First the height animates, then the width animates.

B.   First the width animates, then the height animates.

C.   Both the width and height animates at the same time.

3: What is the equivalent of the following code? $('div').click(function {alert(1);});

A.   $('div').handler('click',function {alert(1);});

B.   $('div').bind('click',function {alert(1);});

C.   $('div').call('click',function {alert(1);});

D.   $('div').event('click',function {alert(1);});

4: $(function(){ //executable code }); The executable code will be run:

A.   after everything has loaded

B.   after everything except other scripts are loaded

C.   after all other javascript has been read and executed

D.   before anything has loaded

E.   after the DOM has loaded, but prior to anything else loading

5: The selector :disabled will perform the following:

A.   Select only elements in a disabled state

B.   Create a new element with the state set to disabled

C.   None of the above

D.   Disable any elements currently set to an enabled state

6: What is the END STATE STYLE of the paragraph element in the code $('p').hide(); ?

A.   visibility: hidden;

B.   display: none;

C.   height: 0;

D.   opacity: 0;

7: What does every selector expression return?

A.   jQuery object

B.   HTML text

C.   result set

D.   recordset

8: What keyword would you use to refer to the object on which the currently executing method has been invoked?

A.   object

B.   here

C.   this

D.   medium

E.   that

9: What is the difference between .width() and .outerWidth()?

A.   No difference. width() is a shorthand alias for outerWidth()

B.   Only difference is .width() returns a number & outerWidth() returns a string.

C.   width() returns the computed width of the element while outerWidth() returns the width plus all the margins and paddings.

10: $() is an alias of the jQuery() function

A.   True

B.   False

11: The '#' symbol indicates a lookup on what?

A.   Name

B.   element

C.   Attribute

D.   element's ID

12: What language is jQuery constructed in?

A.   JavaScript

B.   C++

C.   Java

D.   PHP

13: What language is jQuery written in?

A.   PHP

B.   JavaScript

C.   CSS

D.   Java

14: Which is an id selector?

A.   $(':name')

B.   $('#name')

C.   $('.name')

15: Illustrate the code needed to include the jQuery library in an HTML file:

A.   $(script src)="jQuery.js"(/script)

B.   <script src="jQuery.js"></script>

C.   $script src="jQuery.js"

D.   $(script) src="jQuery.js")

16: Is jQuery a library for client scripting or server scripting?

A.   Server Scripting

B.   Client Scripting

17: Which is a class selector?

A.   $('_name')

B.   $('#name')

C.   $('.name')

18: What do selectors do?

A.   Allows you to select an array in the node list.

B.   Allows the content to be stopped at some point.

C.   Allows you to select HTML elements (or groups of elements) by element name, attribute name or by content.

D.   Allows selection of libraries.

19: Which is NOT a jQuery method?

A.   toggle()

B.   show()

C.   fadeIn()

D.   alias()

20: What does this script do? $(function() { $( "#effect" ).animate({ backgroundColor: "#fff" }, 1000 ); });

A.   Changes the background color of the element with class 'effect' to #fff within 1 second.

B.   Changes the background color of the element with id 'effect' to #fff within 1 second.

21: Is it possible to use jQuery together with AJAX?

A.   No

B.   Yes

22: Which method is used to hide selected elements?

A.   display(none)

B.   hidden()

C.   hide()

D.   hide(display)

23: What does the jQuery attr() function do?

A.   Takes the name of an attribute and duplicates it.

B.   Takes the name of an attribute on your page and gives the value of that attribute.

C.   Takes the name of an attribute on the page and makes it animate.

D.   Takes the element and duplicates it.

24: Which command selects an element using its ID?

A.   ${."myID"}

B.   ${"#myID"}

C.   #{".myID"}

D.   $("#myID")

25: Which selector matches all elements?

A.   #

B.   *

C.   &

D.   ?

26: jQuery uses CSS selectors to select elements?

A.   True

B.   False

27: What is '$();' equivalent to?

A.   java();

B.   Function();

C.   function();

D.   operator();

E.   jQuery();

28: What function can be used to alternate an element's state between display and hidden?

A.   toggle

B.   reverse

C.   alternate

D.   flip

E.   switch

29: Which of the following is the correct command to fade in an element over a three-second time period?

A.   fadeIn('three')

B.   fadeIn(3000)

C.   fadeIn('3 seconds')

D.   fadeIn('3 sec')

E.   fadeIn(3)

30: Which of the following is valid?

A.   $('p').css('color', 'red');

B.   $('p').css('color: red;');

C.   $('p').css('color: red');

31: Illustrate selecting a HTML element using its class:

A.   $('#myClass')

B.   #(".myClass")

C.   $(".myClass")

D.   $("#myClass")

32: Which is a syntactically valid jQuery command?

A.   $("book").fadeOut{}

B.   jQuery("book").fadeOut{}

C.   $(#book).fadeOut();

D.   $("#book").fadeOut();

33: Which function does jQuery provide to remove whitespace from the beginning and end of a string?

A.   $.stripspace( )

B.   jQuery does not provide such function.

C.   $.strip( )

D.   $.trim( )

34: What is the proper way to show an element?

A.   $('#foo').display('show');

B.   $('#foo').style('show');

C.   $('#foo').showElement();

D.   $('#foo').show();

35: How do you test if an element has a specific class?

A.   use .hasThis()

B.   use.class()

C.   use .isClass()

D.   use .hasClass()

E.   use .getClass()

36: Which function is used to make a copy of a selected element?

A.   .copy()

B.   .clone()

C.   .duplicate()

D.   .repeat()

37: Where does jQuery code run?

A.   client browser

B.   client server

C.   host server

D.   host browser

38: What is jQuery used for?

A.   Overcome cross-browser issues

B.   Rapid web development

C.   Simplify JavaScript coding

D.   All of these

39: What is the difference between searching 'find()' and 'children()'

A.   There is no find() function

B.   There is no children() function

C.   Both do similar tasks

D.   The .find() and .children() methods are similar, except that the latter only travels a single level down the DOM tree.

40: What method is used to switch between adding/removing one or more classes (for CSS) from selected elements?

A.   classSwitch()

B.   switch()

C.   switchClass()

D.   toggleClass()

41: jQuery.trim() function is used to ?

A.   Remove Whitespace from beginning & ending of string

B.   trim() is not a valid Jquery function

C.   Remove Whitespace from beginning of string

D.   Remove Whitespace from end of string

42: True or False : jQuery method fadeTo() permits fading to a given opacity.

A.   True

B.   False

43: Which of the following does jQuery NOT integrate seamlessly with?

A.   Java

B.   CSS

C.   HTML

D.   DOM

44: What can be used to append a new paragraph element into a div with id 'mydiv'?

A.   $("div#mydiv").never("

Paragraph

");

B.   $("

Paragraph

").appendTo("div#mydiv");

C.   $("div#mydiv").before("

Paragraph

");

D.   $("

Paragraph

").new("div#mydiv");

45: Which is an example of chaining a jQuery command?

A.   $(#box).fadeOut().fadeIn()

B.   $("#box").fadeOut().fadeIn();

C.   $(“box”).fadeOut().fadeIn()

D.   $(<#box>).fadeOut().fadeIn();

46: How do you schedule a Javascript function to execute as soon as the document has been interpreted by the browser?

A.   .load()

B.   .show()

C.   .ready()

D.   .hide()

47: code for making all div elements 100 pixels high?

A.   $("div").height(100)

B.   $("div").height="100"

C.   $("div").height.pos=100

D.   $("div").height=("100")

48: How do you change the CSS property 'color' of an element?

A.   $("#someID").css("color","red");

B.   $("#someID"))((.style("color","red");

C.   $.css("color:red");

D.   $("#someID").css("color:red");

49: Which of the following is NOT a valid example of a selector filter?

A.   div:left

B.   li:last

C.   p:first

D.   tr:even

E.   tr:odd

50: How do you fetch the first span on the page which has the class 'white'?

A.   $('first.span.white')

B.   $('white;span;first')

C.   $('span.white:first')

D.   $('span; white: first')