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')

51: True or False : It is possible to use relative values for jQuery animate() method.

A.   False

B.   True

52: how do you assign php value in jquery variable?

A.   var member= "<?php echo $member_value; ?>";

B.   var member= <?php $member_value; ?>;

53: In the following statement, which is the selector? $('p').css('color','blue');

A.   blue

B.   p

C.   .css

D.   color

54: Is this a valid statement in jQuery? $("#foo").hide().show().css("color", "red").fadeOut();

A.   Yes

B.   No

55: True or False? live() method has been removed from version 1.9

A.   False

B.   True

56: Which is a state selector?

A.   $('.name')

B.   $(':name')

C.   $('#name')

57: To dynamically set the src attribute of all img elements use:

A.   $(img).setAttribute('src', 'photo.jpg');

B.   $('img').attr('src', 'photo.jpg');

C.   $('img src').set('photo.jpg');

D.   $('img').attr('src').set('photo.jpg');

58: Which of the following selectors is the fastest?

A.   $('.grid12');

B.   $('div+.grid12');

C.   $('#container+div');

D.   $('div');

E.   $('#container');

59: $.foo() is equivalent to:

A.   jQuery.foo()

B.   javascript.foo()

C.   None of them

D.   document.foo()

60: Which statement best described the code snippet: $('#myID').animate({width:'90''fast'

A.   Animate the tag with myID from the current width to 90% width.

B.   Animate the tag with myID from 90% width to 0% width.

C.   Animate the tag with myID from 90% width to 100% width.

D.   Animate the tag with myID from 90% width to the current width.

61: What method is the primary means of attaching a handler to an event?

A.   .on()

B.   .link()

C.   .behavior()

D.   .attach()

62: Which of the following is a subset of jQuery's CSS selectors?

A.   universal selectors

B.   All of these choices are subsets

C.   attribute selectors

D.   child selectors

E.   css3 selectors

63: What does $("div.intro") select?

A.   All div elements with class=

B.   All div elements with id=

C.   The first div element with class=

D.   The first div element with id=

64: How would you prevent the default browser action from an event handler without affecting other properties of the event flow?

A.   $a.click(function (e) { /* code */ e.returnValue = false; });

B.   $a.click(false);

C.   $a.click(function (e) { /* code */ e.preventDefault(); });

D.   $a.click(function () { /* code */ return false; });

65: What character is used to identify a child combinator relationship?

A.   left carat (<)

B.   minus (-)

C.   right carat (>)

D.   medium

E.   plus (+)

66: How do you pass options to a plugin?

A.   $("...").foobar( option1: 123, option2: 9 );

B.   $("...").foobar({ option1: 123, option2: 9 });

C.   $("...").foobar([ option1: 123, option2: 9 ]);

67: What method is used to set one or more style properties for selected elements?

A.   style()

B.   css()

C.   javascript()

D.   html()

68: How do you execute code 2 seconds after the page was loaded.

A.   window.setTimeout(function(){ // some code }, 2);

B.   window.delayed(function(){ // some code }, 2000);

C.   window.timeOut(function(){ // some code }, 2);

D.   window.setTimeout(function(){ // some code }, 2000);

69: Which method is used to bind an event handler to existing and future matching elements?

A.   attach();

B.   click();

C.   .on();

70: Which selector will only return one element?

A.   :one-based()

B.   :even

C.   :odd

D.   :nth-child()

71: What does the $.get() jQuery function do?

A.   It returns the DOM elements that are contained in the jQuery object.

B.   It returns an object

C.   It fires a GET OBJECT request

D.   It fires a GET AJAX request

72: Which of the following is used to schedule a function to execute after an animation has completed?

A.   graceful degradation

B.   progressive enhancement

C.   callback function

D.   chaining

E.   AJAX

73: What does the following code do? $('#mydiv').wrap('
');

A.   duplicate the element id 'mydiv'

B.   Create a parent 'div' tag for element id 'mydiv'.

C.   Create a div next to the element id 'mydiv'

74: What jQuery function is used to add HTML content just outside of a selection?

A.   after()

B.   more()

C.   later()

D.   outside()

75: What does the animate method do?

A.   Allows you to animate any CSS property controlled by an alphabetic value

B.   Allows you to animate CSS property controlled by a numeric value

C.   Allows you to create a cartoon using the DOM

76: Which code is an example of ______: $('.tooltip').hide().fadeIn(9000).delay(1000).fade0ut(9000);

A.   statement

B.   it ends a statement

C.   Chaining

D.   an effect that disables

77: When using jQuery animation, you can specify duration in the following format:

A.   500

B.   All of these

C.   Leave it blank

D.   'fast'

78: If you want to change the text displayed in a paragraph by adding text before what's currently displayed, which would be correct?

A.   $('p').append('text to add');

B.   $('p').content('text to add');

C.   $('p').text('text to add');

D.   $('p').html('text to add');

E.   $('p').prepend('text to add');

79: What jQuery function is used to set an element's markup content?

A.   document.write()

B.   echo()

C.   .content()

D.   .html()

80: How should your JQuery code be wrapped so it executes only once the page has loaded?

A.   $(document).pageloadcomplete(function () { /* Code goes here */ });

B.   document.ready(function () { /* Code goes here */ });

C.   $(document).ready(function () { /* Code goes here */ });

D.   $(document).ready(function { /* Code goes here */ });

E.   $(document).ready({ /* Code goes here */ });

81: True or false? The jQuery library can be used to request a server-side script.

A.   False

B.   True

82: Which part of the following statement is the action? $('p').css('color','blue');

A.   'color'

B.   .css

C.   $('p')

D.   'blue'

83: What does the greater sign (>) indicate in the following code? $('#summary > div').hide();

A.   hierarchical relationship

B.   comparison operator

C.   child selector

D.   directional indicator

E.   chaining

84: You can copy an element by calling which of the following methods?

A.   cloneTo()

B.   clone()

C.   copy()

D.   moveTo()

85: What does $('#myDiv').load('page.html') do?

A.   It adds the string 'page.html' as the contents of the #myDiv div.

B.   it loads the #myDiv on the contents of the 'page.html' browser

C.   it fires an AJAX request, fetches the result of page.html as text, and inserts it into the div

86: What is the difference between remove() & empty()

A.   remove() method removes the selected element(s) and its child elements whereas empty() method removes the child elements of the selected element(s)

B.   they are same

C.   remove() method removes the child elements of the selected element(s) whereas empty() method removes the selected element(s) and its child elements

87: What method selects the sibling element that immediately follows the current one?

A.   next()

B.   next_element()

C.   medium

D.   next_sibling()

E.   sibling()

88: Which term is given to the jQuery feature that allows the attachment of one function to another?

A.   outer join

B.   stringing

C.   concatenation

D.   chaining

89: Which of the following jQuery functions are deprecated?

A.   .die()

B.   .browser()

C.   .live()

D.   .sub()

E.   All of these

90: What does the following code do: $('#myDiv').trigger('click');

A.   It simulates a click on the element and runs all the event handlers associated with it.

B.   It sets up a trigger. When a click occurs, the trigger is going to be activated.

C.   It makes a click on any element and creates a trigger.

D.   When a click occurs the trigger is going to be activated.

91: What method returns control of the $ identifier to other libraries?

A.   .noConflict()

B.   medium

C.   .$()

D.   .library()

E.   .return()

92: What is not a an AjaxEvent.

A.   .ajaxComplete()

B.   .ajaxSend()

C.   .ajaxError()

D.   .ajaxRun()

E.   .ajaxStop()

93: Which one will be found faster?

A.   $('div.element')

B.   $('.element')

C.   $('#element')

D.   $('div#element')

94: The insertAfter function adds a new element as a sibling. What comparable function adds a new element as a child?

A.   appendTo

B.   createChild

C.   insertNew

D.   addChild

E.   expandFamily

95: Why do we add the stop() function before the animate() function?

A.   stop() halts the execution of the scripts on the page until any animations have finished.

B.   stop() ends any currently running animations on the element.

C.   to stop the animation after it has finished.

D.   to tell jQuery that the animation has to be stopped at some point.

96: How to Remove from the queue all items that have not yet been run in jquery?

A.   clearQueue()

B.   hide()

C.   dequeue()

D.   queue()

97: What term refers to the acceleration and deceleration that occurs during an animation?

A.   speeding

B.   velocity

C.   gradient

D.   resizing

E.   easing

98: Which function locates elements at the same level as the current selection?

A.   .find()

B.   .closest()

C.   .children()

D.   .siblings()

99: When an event is triggered on an element, the same event is also triggered on all of that element’s ancestors. What is the name of this process?

A.   global event

B.   event bubbling

C.   upward progress

D.   medium

E.   progressive enhancement

100: Which jQuery method can be used to bind both the mouseover and the mouseout events?

A.   mouse()

B.   switch()

C.   hover()

D.   toggle()

E.   change()