jQuery - Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to jQuery Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following type of variable is visible only within a function where it is defined?

A - global variable

B - local variable

C - Both of the above.

D - None of the above.

Answer : B

Explaination

Local Variables: A local variable will be visible only within a function where it is defined. Function parameters are always local to that function.

Q 2 - Which built-in method returns the index within the calling String object of the first occurrence of the specified value?

A - getIndex()

B - location()

C - indexOf()

D - None of the above.

Answer : C

Explaination

indexOf() method returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.

Q 3 - Which of the following jQuery selector select elements whose css class is some-class?

A - $('some-class')

B - $('#some-class')

C - $('.some-class')

D - None of the above.

Answer : C

Explaination

$('.some-class') selects all elements in the document that have a class of some-class.

Q 4 - Which of the following jQuery method returns true if the specified class is present on at least one of the set of matched elements?

A - hasCSSClass( class )

B - hasStyleClass( class )

C - hasClass( class )

D - None of the above.

Answer : C

Explaination

The hasClass( class ) method returns true if the specified class is present on at least one of the set of matched elements.

Q 5 - Which of the following jQuery method set the value of an element?

A - setContent( val )

B - val( val )

C - setValue( val )

D - None of the above.

Answer : B

Explaination

The val(val) method sets the value attribute of every matched element if it is called on <input> but if it is called on <select> with the passed <option> value then passed option would be selected, if it is called on check box or radio box then all the matching check box and radiobox would be checked.

Q 6 - Which of the following jQuery method gets a set of elements containing all of the unique immediate children of each of the matched set of elements?

A - getChild( selector )

B - children( [selector])

C - getChildren(selector)

D - None of the above.

Answer : B

Explaination

The children( [selector]) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.

Q 7 - Which of the following jQuery method gets the inner height (excluding the border) of an element?

A - getCSSHeight( )

B - innerHeight( )

C - getInnerHeight( )

D - None of the above.

Answer : B

Explaination

The innerHeight( ) method gets the inner height (excludes the border and includes the padding) for the first matched element.

Q 8 - Which of the following jQuery method returns the outer width (including the border) of an element?

A - getCSSWidth( )

B - getWidth( )

C - outerWidth( [margin] )

D - None of the above.

Answer : C

Explaination

The outerWidth( [margin] ) method gets the outer width (includes the border and padding by default) for the first matched element.

Q 9 - Which of the following jQuery method can be used to attach a function to be executed whenever an AJAX request fails?

A - ajaxStart( callback )

B - ajaxComplete( callback )

C - ajaxSend( callback )

D - ajaxError(callback)

Answer : D

Explaination

The ajaxError( callback ) method can be used to attach a function to be executed whenever an AJAX request fails.

Q 10 - Which of the following jQuery method can be used to attach a function to be executed whenever AJAX request completed successfully?

A - ajaxStart( callback )

B - ajaxSuccess( callback )

C - ajaxSend( callback )

D - ajaxStop(callback)

Answer : B

Explaination

The ajaxSuccess( callback ) method can be used to attach a function to be executed whenever AJAX request completed successfully.

jquery_questions_answers.htm
Advertisements