Solved Objective Questions on jQuery Library set-1

1) Which of the following statements about the features of jQuery are True.

i) jQuery has an expressive syntax for referring to elements in the document.

ii) jQuery has an efficient query method for finding the set of document elements that match a CSS selector.

iii) jQuery has a useful set of methods for manipulating selected elements.

A. i, ii and iii only

B. i, ii and iv only

C. i, iii and iv only

D. All i, ii, iii and iv


2) If you are using $ in your own code, or are using another library, such as prototype, that uses $, you can call .......... to restore $ to its original value.

A. jQuery.noConflict()

B. jQuery.removeConflict()

C. jQuery.restoreDefault()

D. jQuery.restoreFunction()


3) Which of the following is/are the sources of Content Distribution Network(CDN) for jQuery.

A. jQuery CDN

B. Microsoft CDN

C. Google CDN

D. All of the above


4) Which of the following are the different ways of invoking jQuery() function.

i) invoke $() is to pass a CSS selector to it

ii) invoke $() is to pass an element or document or window object

iii) invoke $() is to pass a string of JavaScript code

iv) invoke $() is to pass a function to it

A. i, ii and iii only

B. i, ii and iv only

C. i, iii and iv only

D. All i, ii, iii and iv


5) The jQuery library defines a number of utility functions, one of them is ............ function for general purpose iteration and another is ............ function for parsing JSON text.

A. jQuery.each(), jQuery.JSONtext()

B. jQuery.iterate(), jQuery.parseJSON()

C. jQuery.each(), jQuery.parseJSON()

D. jQuery.general(), jQuery.parseJSON()


6) The value returned by $() are ......... ,they are array like, they have a length property and have numeric properties from o to length -1.

A. jQuery result

B. jQuery objects

C. jQuery array

D. jQuery length


7) In order to loop over all elements in a jQuery object, you can call the .......... method instead of writing a for loop.

A. array.map()

B. index()

C. each()

D. map()


8) ......... method expects a callback function as its sole argument, and it invokes that callback function once for each element in the jQuery object in document order.

A. array.map()

B. index()

C. each()

D. map()


9) ........... accepts a callback function as its argument and invokes that function once for each element of the jQuery object.

A. is()

B. index()

C. each()

D. map()


10) ........ takes a selector as its argument and returns true if at least one of the selected elements also matches the specified selector.

A. is()

B. index()

C. each()

D. map()



11) ........ handles browser incompatibilities and special cases and allows you to use either HTML attribute names of their JavaScript property equivalents.

A. attr()

B. removeattr()

C. handleattr()

D. useattr()


12) Match the following methods for working with the class attribute defined by jQuery with their definitions.

i) addClass()           a) tests for the presence of specified class

ii) toggleClass()      b) adds classes to elements that don't already have

iii) hasClass()          c) remove classes from selected elements

iv) removeClass()   d) adds classes from selected elements

A. i-b, ii-c, iii-d, iv-a

B. i-c, ii-d, iii-a, iv-b

C. i-d, ii-c, iii-b, iv-a

D. i-d, ii-b, iii-a, iv-c


13) ........ is a method for setting and querying the value attribute of HTML form elements and also for querying and setting the selection state of check boxes, radio buttons and <select> elements.

A. set()

B. val()

C. query()

D. attr()


14) In jQuery, .......... method measures positions relative to the document and returns them in the form of an object with left and top properties that hold the X and Y coordinates.

A. offset()

B. position()

C. offsetparent()

D. setparent()


15) The .......... method is like offset(), except that it is a getter only and it returns element positions relative to their offset parent, rather to the document as a whole.

A. width()

B. position()

C. offsetparent()

D. setparent()


Answers

1) D. All i, ii, iii and iv
2) A. jQuery.noConflict()
3) D. All of the above
4) B. i, ii and iv only
5) C. jQuery.each(), jQuery.parseJSON()
6) B. jQuery objects
7) C. each()
8) C. each()
9) D. map()
10) A. is()
11) A. attr()
12) D. i-d, ii-b, iii-a, iv-c
13) B. val()
14) A. offset()
15) B. position()

For more Multiple Choice Questions (MCQs): Click Here