14 Sep 100 jQuery MCQ (Multiple Choice Questions) with Answers
Show Answer
Explanation
2) Who created jQuery?
Show Answer
Explanation
3) In which year was jQuery first released?
Show Answer
Explanation
4) Which symbol is used as an alias for jQuery?
Show Answer
Explanation
jQuery object.5) Which method is used to wait for the document to be ready?
Show Answer
Explanation
6) What is the correct syntax to select all <p> elements?
Show Answer
Explanation
7) Which selector selects an element with id=”demo”?
Show Answer
Explanation
$("#demo") selects the element with id="demo".8) Which selector selects all elements with class=”test”?
Show Answer
Explanation
$(".test") matches every element carrying that class.9) What does $(“div p”) select?
Show Answer
Explanation
$("div p") selects all paragraphs nested anywhere inside a div.10) Which method is used to hide an element?
Show Answer
Explanation
11) Which method is used to show an element?
Show Answer
Explanation
12) Which method is used to toggle hide/show?
Show Answer
Explanation
13) Which method fades out an element?
Show Answer
Explanation
14) Which method slides an element up?
Show Answer
Explanation
15) Which method is used for custom animations?
Show Answer
Explanation
16) Which method stops an ongoing animation?
Show Answer
Explanation
17) Which method is used to add a class to selected elements?
Show Answer
Explanation
18) Which method removes a class?
Show Answer
Explanation
19) Which method toggles a class?
Show Answer
Explanation
20) Which method sets or returns CSS properties?
Show Answer
Explanation
21) Which method sets or returns attributes?
Show Answer
Explanation
href, src, title or data-*.22) Which method sets or returns the value of form fields?
Show Answer
Explanation
23) Which method sets or returns the text content?
Show Answer
Explanation
24) Which method sets or returns the HTML content?
Show Answer
Explanation
25) Which method appends content to selected elements?
Show Answer
Explanation
26) Which method prepends content?
Show Answer
Explanation
27) Which method inserts content after selected elements?
Show Answer
Explanation
28) Which method inserts content before selected elements?
Show Answer
Explanation
29) Which method removes selected elements?
Show Answer
Explanation
30) Which method removes child elements?
Show Answer
Explanation
31) Which method is used to bind an event handler?
Show Answer
Explanation
bind() and the shorthand click() are older forms, while on() is the modern, preferred one.32) Which method is the preferred way to attach events in jQuery 1.7+?
Show Answer
Explanation
33) Which method is used to remove event handlers?
Show Answer
Explanation
on(), while unbind() and undelegate() are the older APIs.34) Which method triggers the click event?
Show Answer
Explanation
click() with no argument triggers the event, and trigger("click") does exactly the same thing.35) Which method is used for AJAX requests?
Show Answer
Explanation
$.ajax() is the low-level method; $.get() and $.post() are convenience shortcuts built on top of it.36) Which method loads data from server and places it into selected element?
Show Answer
Explanation
37) Which method performs an AJAX GET request?
Show Answer
Explanation
38) Which method performs an AJAX POST request?
Show Answer
Explanation
39) What is the correct syntax for $.ajax?
Show Answer
Explanation
$.ajax() accepts either a settings object or a URL string, so all three forms are valid.40) Which method is used to iterate over a jQuery object?
Show Answer
Explanation
41) Which method is used to iterate over arrays and objects?
Show Answer
Explanation
.each()).42) Which method is used to filter an array?
Show Answer
Explanation
43) Which method is used to translate all items in an array to a new array?
Show Answer
Explanation
44) Which method removes whitespace from both ends of a string?
Show Answer
Explanation
45) Which method is used to merge the contents of two arrays?
Show Answer
Explanation
46) Which method is used to find elements within a selected element?
Show Answer
Explanation
47) Which method reduces the set of matched elements to those that match the selector?
Show Answer
Explanation
48) Which method removes elements from the set?
Show Answer
Explanation
filter() — it removes the elements that match the selector from the set.49) Which method gets the children of each element?
Show Answer
Explanation
50) Which method gets the parent of each element?
Show Answer
Explanation
51) Which method gets all ancestors?
Show Answer
Explanation
52) Which method gets siblings?
Show Answer
Explanation
53) Which method gets the next sibling?
Show Answer
Explanation
54) Which method gets the previous sibling?
Show Answer
Explanation
55) Which method is used to chain multiple jQuery methods?
Show Answer
Explanation
56) What does $(“div”).css(“color”, “red”).slideUp(2000).slideDown(2000); demonstrate?
Show Answer
Explanation
57) Which method is used to add a function to jQuery?
Show Answer
Explanation
jQuery.prototype) makes the new function available on every jQuery object.58) What is the purpose of jQuery.noConflict()?
Show Answer
Explanation
$ variable so other libraries (like Prototype) can use it, letting you reference jQuery by name instead.59) Which method is used to set multiple CSS properties?
Show Answer
Explanation
60) Which method is used to get the position of an element?
Show Answer
Explanation
offset() relative to the document and position() relative to the offset parent.61) Which method gets the offset relative to the document?
Show Answer
Explanation
{top, left}.62) Which method gets the position relative to the offset parent?
Show Answer
Explanation
63) Which method is used to scroll to a specific position?
Show Answer
Explanation
scrollTop() or scrollLeft() scrolls the element vertically or horizontally to that position.64) Which method is used to get the width of an element?
Show Answer
Explanation
width() excludes padding; innerWidth() includes padding; outerWidth() adds borders (and optionally margins).65) Which method is used to get the height of an element?
Show Answer
Explanation
height(), innerHeight() and outerHeight() mirror the three width methods for vertical measurement.66) Which method is used to remove an event handler from an element?
Show Answer
Explanation
off() being the modern API, with unbind() and undelegate() retained for backwards compatibility.67) Which method is used to attach an event handler that runs only once?
Show Answer
Explanation
68) Which method is used to trigger a custom event?
Show Answer
Explanation
trigger() runs handlers and the default action; triggerHandler() runs handlers only and does not bubble — both fire custom events.69) Which method is used to prevent the default action of an event?
Show Answer
Explanation
preventDefault() cancels the browser’s default behaviour, and return false does the same (plus stops propagation) inside a jQuery handler.70) Which method is used to stop event bubbling?
Show Answer
Explanation
stopPropagation() halts bubbling up the DOM, and return false also stops propagation inside jQuery handlers.71) Which method is used to create a new element?
Show Answer
Explanation
$("<div>") creates a new element, and the native document.createElement() also works when wrapped in jQuery.72) Which method is used to add content to the end of selected elements?
Show Answer
Explanation
appendTo() is the mirror-image form written from the content’s perspective.73) Which method is used to add content to the beginning of selected elements?
Show Answer
Explanation
prependTo() is the reversed-perspective counterpart.74) Which method is used to insert content after selected elements?
Show Answer
Explanation
insertAfter() achieves the same result written from the content’s side.75) Which method is used to insert content before selected elements?
Show Answer
Explanation
insertBefore() is the equivalent reversed-perspective method.76) Which method is used to replace selected elements?
Show Answer
Explanation
replaceAll() is the same operation expressed from the other direction.77) Which method is used to wrap selected elements?
Show Answer
Explanation
wrap() wraps each element, wrapAll() wraps the whole set in one wrapper, and wrapInner() wraps each element’s contents.78) Which method is used to remove the parents of selected elements?
Show Answer
Explanation
79) Which method is used to clone selected elements?
Show Answer
Explanation
80) Which method is used to check if an element has a class?
Show Answer
Explanation
81) Which method is used to get the index of an element?
Show Answer
Explanation
82) Which method is used to get the DOM element at a specific index?
Show Answer
Explanation
83) Which method is used to reduce the set to a specific index?
Show Answer
Explanation
84) Which method is used to get the first element?
Show Answer
Explanation
first() and eq(0) both reduce the set to its first element as a jQuery object; get(0) returns the raw DOM node instead.85) Which method is used to get the last element?
Show Answer
Explanation
last() and eq(-1) both select the final element of the set as a jQuery object.86) Which method is used to check if any element matches a selector?
Show Answer
Explanation
87) Which method is used to get the descendants of each element?
Show Answer
Explanation
88) Which method is used to get all siblings until a selector?
Show Answer
Explanation
nextUntil() walks forward and prevUntil() walks backward, stopping when the given selector is reached.89) Which method is used to get all parents until a selector?
Show Answer
Explanation
90) Which method is used to get the closest ancestor that matches a selector?
Show Answer
Explanation
91) Which method is used to add elements to the set?
Show Answer
Explanation
92) Which method is used to add elements to the set and then remove duplicates?
Show Answer
Explanation
$.uniqueSort() helper).93) Which method is used to get the number of elements in the set?
Show Answer
Explanation
length is the property and size() was the older method, now deprecated in jQuery 3.0.94) Which property gives the number of elements in a jQuery object?
Show Answer
Explanation
95) Which method is deprecated in jQuery 3.0?
Show Answer
Explanation
length property instead.96) Which method is used to bind an event that runs when the DOM is ready?
Show Answer
Explanation
97) Which method is used to unbind all event handlers from an element?
Show Answer
Explanation
off() or unbind() with no arguments removes every handler attached to the element.98) Which method is used to execute a function when an AJAX request completes successfully?
Show Answer
Explanation
success option and the modern promise method done() both run when the request succeeds.99) Which method is used to execute a function when an AJAX request fails?
Show Answer
Explanation
error callback and the modern promise method fail() both handle a failed request.100) Which method is used to execute a function always when an AJAX request completes (success or failure)?
No Comments