Home »
MCQs
jQuery Multiple-Choice Questions (MCQs)
jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax. It is free, open-source software using the permissive MIT License.
jQuery MCQs: This section contains jQuery Multiple-Choice Questions with Answers. These jQuery MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of jQuery.
List of jQuery MCQs
1. jQuery is a ______.
- JavaScript Library
- JSON Library
- Java Library
- JSON and CSS Library
Answer: A) JavaScript Library
Explanation:
jQuery is a JavaScript Library.
Discuss this Question
2. To work with jQuery, you should have the basic knowledge of these topics?
- HTML
- CSS
- JavaScript
- All of the above
Answer: D) All of the above
Explanation:
To work with jQuery, you should have the basic knowledge of HTML, CSS, and JavaScript.
Discuss this Question
3. Who developed jQuery?
- John Richard
- John Resig
- John Carter
- John Alexander
Answer: B) John Resig
Explanation:
John Resig developed jQuery.
Discuss this Question
4. In which year jQuery was initial released?
- 2004
- 2005
- 2006
- 2007
Answer: C) 2006
Explanation:
jQuery was initial released on August 26, 2006.
Discuss this Question
5. Is jQuery case-sensitive?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, jQuery is case-sensitive.
Discuss this Question
6. Which feature(s) jQuery contains?
- HTML/DOM manipulation
- CSS manipulation
- HTML event methods
- Effects and animations
- AJAX
- Utilities
- All of the above
Answer: G) All of the above
Explanation:
All of the above features jQuery contains.
Discuss this Question
7. Which sign is used to define/access jQuery?
- $
- .
- &
- #
Answer: A) $
Explanation:
$ sign is used to define/access jQuery.
Discuss this Question
8. Which jQuery is used to hide the current element?
- $(this).hideelement()
- $(this).hide('true')
- $(this).hide(0)
- $(this).hide()
Answer: D) $(this).hide()
Explanation:
The $(this).hide() method is used to hide the current element.
Discuss this Question
9. Which is the correct jQuery statement to hide all <div> elements?
- $("div").hide()
- $(div).hide()
- $(".div").hide()
- $("#div").hide()
Answer: A) $("div").hide()
Explanation:
The $("div").hide() statement can be used to hide all <div> elements.
Discuss this Question
10. Which is the correct jQuery statement to hide all elements having class name "new"?
- $("new").hide()
- $(new).hide()
- $(".new").hide()
- $("#new").hide()
Answer: C) $(".new").hide()
Explanation:
The $(".new").hide() statement can be used to hide all elements having class name "new".
Discuss this Question
11. Which is the correct jQuery statement to hide all elements having id name "new"?
- $("new").hide()
- $(new).hide()
- $(".new").hide()
- $("#new").hide()
Answer: D) $("#new").hide()
Explanation:
The $("#new").hide() statement can be used to hide all elements having id name "new".
Discuss this Question
12. What is the use of jQuery Selectors?
- jQuery selectors are used to select and manipulate HTML element(s).
- jQuery selectors are used to import the HTML elements from the other file.
- jQuery selectors are used to select and manipulate JSON elements(s).
- jQuery selectors are used to select and manipulate ReactJS classes.
Answer: A) jQuery selectors are used to select and manipulate HTML element(s)
Explanation:
jQuery selectors are used to select and manipulate HTML element(s).
Discuss this Question
13. Which is the correct jQuery selector statement to select all <div> elements?
- $(".div")
- $("#div")
- $("div")
- $("<div>")
Answer: C) $("div")
Explanation:
The statement $("div") is the correct syntax to select all <div> elements.
Discuss this Question
14. Which sign is used for class selector?
- $class
- .class
- #class
- None
Answer: C) .class
Explanation:
The dot sign (.) i.e., .class is used for the class selector.
Discuss this Question
15. Which sign is used for id selector?
- $id
- .id
- #id
- None
Answer: C) #id
Explanation:
The hash sign (#) i.e., #id is used for the id selector.
Discuss this Question
16. Why #id selectors are used for?
- To select all elements having the id
- To select all elements without having the id
- To select all elements having the id within a specified <div>
- To select all elements having the id within a specified section.
Answer: C) To select all elements having the id within a specified <div>
Explanation:
The #id selectors are used to select all elements having the id.
Discuss this Question
17. Which is the correct jQuery selector to select all elements?
- $("all")
- $("*.*")
- $("*")
- $("***")
Answer: C) $("*")
Explanation:
The $("*") selector is used to select all elements.
Discuss this Question
18. Which is the correct jQuery selector to select current HTML element?
- $(this)
- $(cur)
- $(.this)
- $(#this)
Answer: A) $(this)
Explanation:
The $(this) selector is used to select current HTML elements.
Discuss this Question
19. Which is the correct jQuery selector to select all <div> elements with class name "new"?
- $(".new")
- $("div.new")
- $(".div.new")
- $(".div#new")
Answer: B) $("div.new")
Explanation:
The $("div.new") selector is used to select all <div> elements with class name "new".
Discuss this Question
20. Which is the correct jQuery selector to select the first HTML element?
- $("element_name.first")
- $("element_name#first")
- $("element_name::first")
- $("element_name:first")
Answer: D) $("element_name:first")
Explanation:
The $("element_name:first") selector is used to select the first HTML element.
Discuss this Question
21. Which is the correct jQuery selector to select the first <div> of the HTML document?
- $("div.first")
- $("div#first")
- $("div::first")
- $("div:first")
Answer: D) $("div:first")
Explanation:
The $("div:first") selector is used to select the first <div> of the HTML document.
Discuss this Question
22. Which is the correct jQuery selector to select the first list item of <ul> element?
- $("ul li:first")
- $("ul:first")
- $("li:first")
- $("ul.li:first")
Answer: A) $("ul li:first")
Explanation:
The $("ul li:first") selector is used to select the first list item of <ul> element.
Discuss this Question
23. Which is the correct jQuery selector to select the first list item of every <ul> element?
- $("ul li:first-child")
- $("ul li:first.*")
- $("li:first-child")
- $("ul:first-child")
Answer: A) $("ul li:first-child")
Explanation:
The $("ul li:first-child") selector is used to select the first list item of every <ul> element.
Discuss this Question
24. Which is the correct jQuery selector to select all elements having "href" attribute?
- $("a.[href]")
- $("a:[href]")
- $("[href].*")
- $("[href]")
Answer: D) $("[href]")
Explanation:
The $("[href]") selector is used to select all elements having href attribute.
Discuss this Question
25. Which is the correct jQuery selector to select all <button> elements and <input> elements with type="input"?
- $(".button")
- $(":button")
- $("button","input type="button")
- $(":button,:input")
Answer: B) $(":button")
Explanation:
The $(":button") selector is used to select all <button> elements and <input> elements with type="input".
Discuss this Question
26. Which is the correct jQuery selector to select all even table rows?
- $("tr::even")
- $("tr.even")
- $("tr:even")
- $("tr:#even")
Answer: C) $("tr:even")
Explanation:
The $("tr:even") selector is used to select all even table rows.
Discuss this Question
27. Which is the correct jQuery selector to select all odd table rows?
- $("tr::odd")
- $("tr.odd")
- $("tr:odd")
- $("tr:#odd")
Answer: C) $("tr:odd")
Explanation:
The $("tr:odd") selector is used to select all odd table rows.
Discuss this Question
28. Which method is used to attach an event handler function to an HTML element on mouse click?
- click()
- Click()
- dblclick()
- DblClick()
Answer: A) click()
Explanation:
The jQuery method click() is used to attach an event handler function to an HTML element on mouse click.
Discuss this Question
29. Which method is used to attach an event handler function to an HTML element on mouse double click?
- click()
- Click()
- dblclick()
- DblClick()
Answer: C) dblclick()
Explanation:
The jQuery method dblclick() is used to attach an event handler function to an HTML element on mouse double click.
Discuss this Question
30. Which method is used to attach an event handler function to an HTML element when the mouse pointer enters the HTML element?
- mouseover()
- mousevisit()
- mouse-enter()
- mouseenter()
Answer: D) mouseenter()
Explanation:
The jQuery method mouseenter() is used to attach an event handler function to an HTML element when the mouse pointer enters the HTML element.
Discuss this Question
31. Which method is used to attach an event handler function to an HTML element when the mouse pointer leaves the HTML element?
- mouseLeave()
- mouseleave()
- mouse-leave()
- mouseexit()
Answer: B) mouseleave()
Explanation:
The jQuery method mouseleave() is used to attach an event handler function to an HTML element when the mouse pointer leaves the HTML element.
Discuss this Question
32. Which method is used to attach an event handler function to an HTML element when the left, middle or right mouse button is pressed down, while the mouse is over the HTML element?
- mousedown()
- mouseover()
- mousepress()
- mousekey()
Answer: A) mousedown()
Explanation:
The jQuery method mousedown() is used to attach an event handler function to an HTML element when the left, middle or right mouse button is pressed down, while the mouse is over the HTML element.
Discuss this Question
33. Which method is used to attach an event handler function to an HTML element when the left, middle or right mouse button is released, while the mouse is over the HTML element?
- mouseup()
- mouseover()
- mouseabove()
- mousekey()
Answer: A) mouseup()
Explanation:
The jQuery method mouseup() is used to attach an event handler function to an HTML element when the left, middle or right mouse button is released, while the mouse is over the HTML element.
Discuss this Question
34. Which method is used to attach an event handler function to an HTML element when the mouse moves over the HTML elements?
- mousemove()
- mouseover()
- hover()
- mousehover()
Answer: C) hover()
Explanation:
The jQuery method hover() is used to attach an event handler function to an HTML element when the mouse moves over the HTML elements.
Discuss this Question
35. Which method is used to attach an event handler function to an HTML element when the form field gets focus?
- focused()
- focuses()
- focuselement()
- focus()
Answer: D) focus()
Explanation:
The jQuery method focus() is used to attach an event handler function to an HTML element when the form field gets focus.
Discuss this Question
36. Which method is used to attach an event handler function to an HTML element when the form field loses focus?
- blur()
- leave()
- focusleave()
- leavefocus()
Answer: A) blur()
Explanation:
The jQuery method blur() is used to attach an event handler function to an HTML element when the form field loses focus.
Discuss this Question
37. Which method is used to attach one or more event handlers for the selected elements?
- at()
- atelements()
- on()
- focuson()
Answer: C) on()
Explanation:
The jQuery method on() is used to attach one or more event handlers for the selected elements.
Discuss this Question
38. What is the use of jQuery method toggle()?
- To hide shown elements and to show hidden elements
- To remove current element
- To shift current element at the previous position
- All of the above
Answer: A) To hide shown elements and to show hidden elements
Explanation:
The toggle() method is used to hide the shown elements and to show the hidden elements.
Discuss this Question
39. Which jQuery method is used to fade in a hidden element?
- fade()
- fadeIn()
- fadeOut()
- fadeToggle()
Answer: B) fadeIn()
Explanation:
The jQuery fadeIn() method is used to fade in a hidden element.
Discuss this Question
40. What is the syntax of jQuery fadeIn() method?
- $(selector).fadeIn();
- $(selector).fadeIn(callback, speed);
- $(selector).fadeIn(callback);
- $(selector).fadeIn(speed,callback);
Answer: D) $(selector).fadeIn(speed,callback);
Explanation:
The syntax of jQuery method fadeIn() is:
$(selector).fadeIn(speed,callback);
Discuss this Question
41. Which jQuery method is used to fade out a visible element?
- fadeout()
- fadeIn()
- fadeOut()
- fadeToggle()
Answer: C) fadeOut()
Explanation:
The jQuery fadeOut() method is used to fade out a visible element.
Discuss this Question
42. What is the syntax of jQuery fadeOut() method?
- $(selector).fadeOut();
- $(selector).fadeOut(callback, speed);
- $(selector).fadeOut(callback);
- $(selector).fadeOut(speed,callback);
Answer: D) $(selector).fadeOut(speed,callback);
Explanation:
The syntax of jQuery method fadeOut() is:
$(selector).fadeOut(speed,callback);
Discuss this Question
43. Which jQuery method toggles between the fadeIn() and fadeOut() methods?
- toggle()
- Toggle()
- fadeToggle()
- fadetoggle()
Answer: C) fadeToggle()
Explanation:
The jQuery fadeToggle() method toggles between the fadeIn() and fadeOut() methods.
Discuss this Question
44. What is the syntax of jQuery fadeToggle() method?
- $(selector).fadeToggle();
- $(selector).fadeToggle(callback, speed);
- $(selector).fadeToggle(callback);
- $(selector).fadeToggle(speed,callback);
Answer: D) $(selector).fadeToggle(speed,callback);
Explanation:
The syntax of jQuery method fadeToggle() is:
$(selector).fadeToggle(speed,callback);
Discuss this Question
45. Which jQuery method allows fading to a given opacity (value between 0 and 1)?
- fade()
- fadeOpacity()
- fadeTo()
- fadeto()
Answer: C) fadeTo()
Explanation:
The jQuery fadeTo() method allows fading to a given opacity (value between 0 and 1).
Discuss this Question
46. Which is the correct jQuery statement to fade out a <p> element?
- $("p").fadeOut();
- $("#p").fadeOut();
- $(".p").fadeOut();
- $("p").fadeout();
Answer: A) $("p").fadeOut();
Explanation:
The jQuery statement to fade out a p elements is:
$("p").fadeOut();
Discuss this Question
47. Which is the correct jQuery statement to fade out a <p> element with duration effect "slow"?
- $("p").fadeOut("slow");
- $("#p").fadeOut("slow");
- $(".p").fadeOut("slow");
- $("p").fadeout();
Answer: A) $("p").fadeOut("slow");
Explanation:
The jQuery statement to fade out a <p> elements with duration effect "slow" is:
$("p").fadeOut("slow");
Discuss this Question
48. Which jQuery method is used to slide down an element?
- slideBottom()
- slideDown()
- slidedown()
- slide()
Answer: B) slideDown()
Explanation:
The jQuery slideDown() method is used to slide down an element.
Discuss this Question
49. Which jQuery method is used to slide up an element?
- slideUp()
- slideBottom()
- slidebottom()
- slide()
Answer: A) slideUp()
Explanation:
The jQuery slideUp() method is used to slide up an element.
Discuss this Question
50. Which jQuery method toggles between the slideDown() and slideUp() methods?
- slide ()
- slideSwitch()
- slidetoggle()
- slideToggle()
Answer: D) slideToggle()
Explanation:
The jQuery slideToggle() method toggles between the slideDown() and slideUp() methods.
Discuss this Question
51. Which jQuery method is used to create custom animations?
- animation()
- slidAnimate()
- animate()
- SlideAnimate()
Answer: C) animate()
Explanation:
The jQuery animate() method is used to create custom animations.
Discuss this Question
52. What is the correct syntax of animate() method?
- $(selector).animate({params},speed,callback);
- $(#selector).animate({params},speed,callback);
- $(selector).animate(speed,callback);
- $(selector).animate({speed,callback,params});
Answer: A) $(selector).animate({params},speed,callback);
Explanation:
The correct syntax of animate() method is:
$(selector).animate({params},speed,callback);
Discuss this Question
53. In the syntax of animate() method, why params parameter is used?
- It is used to define the speed of the animation
- It is used to define the mouse events on the HTML element
- It is used to define the CSS property to be animated
- None of the above
Answer: C) It is used to define the CSS property to be animated
Explanation:
The params parameter of jQuery animate() method is used to define the CSS property to be animated.
Discuss this Question
54. In the syntax of animate() method, what is/are the valid value(s) of speed parameter?
- slow
- fast
- milliseconds
- All of the above
Answer: D) All of the above
Explanation:
The following are the correct value of the speed parameter are:
Discuss this Question
55. Which jQuery method is used to stop an animation before it is finished?
- animate(false)
- animate('false')
- animate("false")
- stop()
Answer: D) stop()
Explanation:
The jQuery method stop() is used to stop an animation before it is finished.
Discuss this Question
56. What is the correct syntax of stop() method?
- $(selector).stop(stopAll,goToEnd);
- $(selector).stop(speed,callback);
- $(selector).stop(stopAll,goToEnd,callback);
- $(selector).stop(stopAll,speed);
Answer: A) $(selector).stop(stopAll,goToEnd);
Explanation:
The correct syntax of stop() method is:
$(selector).stop(stopAll,goToEnd);
Discuss this Question
57. In jQuery DOM, what does DOM stand for?
- Data Object Model
- Document Object Manipulation
- Document Object Model
- Document On Model
Answer: D) Document Object Model
Explanation:
In jQuery DOM, DOM stands for Document Object Model.
Discuss this Question
58. Which jQuery DOM method is used to set or return the text content of selected elements?
- content()
- text()
- html()
- val()
Answer: B) text()
Explanation:
The jQuery DOM method text() is used to set or return the text content of selected elements.
Discuss this Question
59. Which jQuery DOM method is used to set or return the content of selected elements (including HTML markup)?
- content()
- text()
- html()
- val()
Answer: C) html()
Explanation:
The jQuery DOM method html() is used to set or return the content of selected elements (including HTML markup).
Discuss this Question
60. Which jQuery DOM method is used to set or return the value of form fields?
- content()
- text()
- html()
- val()
Answer: D) val()
Explanation:
The jQuery DOM method val() is used to set or return the value of form fields.
Discuss this Question
61. Which is the correct jQuery statement to get the text content of an HTML element having id "notification"?
- $("notification").text()
- $("#notification").text()
- $(".notification").text()
- $("#notification").val()
Answer: B) $("#notification").text()
Explanation:
The jQuery statement $("#notification").text() will return the text content of the HTML document having id "notification".
Discuss this Question
62. Which jQuery DOM method is used to get the attribute value?
- attr()
- attribute()
- attrib()
- val()
Answer: A) attr()
Explanation:
The jQuery DOM method attr() is used to get the attribute value.
Discuss this Question
63. Which is the correct jQuery statement to get the value "href" attribute having id "top"?
- $("top").attr("href")
- $(".top").attr("href")
- $("$top").attr("href")
- $("#top").attr("href")
Answer: D) $("#top").attr("href")
Explanation:
The jQuery statement $("#top").attr("href") will return the the value href attribute having id "top".
Discuss this Question
64. Which jQuery DOM method is used to insert content at the end of the selected elements?
- insert()
- add()
- append()
- appendValue()
Answer: C) append()
Explanation:
The jQuery DOM method append() is used to insert content at the end of the selected elements.
Discuss this Question
65. Which jQuery DOM method is used to insert content at the beginning of the selected elements?
- insert()
- before()
- append()
- prepend()
Answer: D) prepend()
Explanation:
The jQuery DOM method prepend() is used to insert content at the beginning of the selected elements.
Discuss this Question
66. Which jQuery DOM method is used to insert content after the selected elements?
- after()
- postpend()
- addafter()
- prepend()
Answer: A) after()
Explanation:
The jQuery DOM method after() is used to insert content after the selected elements.
Discuss this Question
67. Which jQuery DOM method is used to insert content before the selected elements?
- before()
- addbefore()
- addprepend()
- prepend()
Answer: A) before()
Explanation:
The jQuery DOM method before() is used to insert content before the selected elements.
Discuss this Question
68. Which is the correct syntax to insert content at the end of the <p> elements?
- $("#p").append("Text to be added");
- $("p").before("Text to be added");
- $("p").append("Text to be added");
- $("p").prepend("Text to be added");
Answer: C) $("p").append("Text to be added");
Explanation:
The correct syntax to insert content at the end of the <p> elements is:
$("p").append("Text to be added");
Discuss this Question
69. Which is the correct syntax to insert content at the beginning of the <p> elements?
- $("#p").before("Text to be added");
- $("p").addafter("Text to be added");
- $("p").after("Text to be added");
- $("p").prepend("Text to be added");
Answer: D) $("p").prepend("Text to be added");
Explanation:
The correct syntax to insert content at the beginning of the <p> elements is:
$("p").prepend("Text to be added");
Discuss this Question
70. Which is the correct syntax to insert content after the <div> elements?
- $("div").after("Text to be added");
- $("div").postpend("Text to be added");
- $("div").addafter("Text to be added");
- $("#div").after("Text to be added");
Answer: A) $("div").after("Text to be added");
Explanation:
The correct syntax to insert content after the <div> elements is:
$("div").after("Text to be added");
Discuss this Question
71. Which is the correct syntax to insert content before the <div> elements?
- $("div").before("Text to be added");
- $("div").pretpend("Text to be added");
- $("div").addbefore("Text to be added");
- $("#div").before("Text to be added");
Answer: A) $("div").before("Text to be added");
Explanation:
The correct syntax to insert content before the <div> elements is:
$("div").before("Text to be added");
Discuss this Question
72. What is the difference between remove() and empty() methods?
- remove() removes the selected element and its child elements while empty() removes the child elements of the selected element
- remove() removes the child elements of the selected element while empty() removes the selected elements and its child elements
- remove() removes the child elements while empty() removes the content of the selected element
- remove() removes the child elements while empty() removes the content of the selected element and its child elements
Answer: A) remove() removes the selected element and its child elements while empty() removes the child elements of the selected element
Explanation:
The difference between remove() and empty() methods is: remove() removes the selected element and its child elements while empty() removes the child elements of the selected element.
Discuss this Question
73. Write a jQuery statement to remove all child elements only from the element having id "notif"?
- $("notif").empty();
- $("#notif").empty();
- $(".notif").empty();
- $("<notif>").empty();
Answer: B) $("#notif").empty();
Explanation:
The jQuery statement to remove all child elements only from the element having id "notif" is:
$("#notif").empty();
Discuss this Question
74. Write a jQuery statement to remove all <p> elements with class="prog"?
- $(".prog").remove();
- $("p").empty(".prog");
- $("p").remove(".prog");
- $("p.prog").remove();
Answer: C) $("p").remove(".prog");
Explanation:
The jQuery statement to removes all <p> elements with class="prog" is:
$("p").remove(".prog");
Discuss this Question
75. Write a jQuery statement to remove all <pre> elements with class="prog" and class="old"?
- $(".prog#old").remove();
- $("pre").empty(".prog",".old");
- $("pre").remove(".prog, .old");
- $("pre.prog.old").remove();
Answer: C) $("pre").remove(".prog, .old");
Explanation:
The jQuery statement to remove all <pre> elements with class="prog" and class="old" is:
$("pre").remove(".prog, .old");
Discuss this Question
76. Which method is used to add CSS class to the selected elements?
- add()
- addClass()
- addClasses()
- AddClasses()
Answer: B) addClass()
Explanation:
The jQuery method addClass() is used to add CSS class to the selected elements.
Discuss this Question
77. Can we add more than one CSS classes to the selected elements using the addClass() method?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, we can add more than one CSS classes to the selected elements using the addClass() method.
Discuss this Question
78. Which method is used to remove CSS class to the selected elements?
- removeCSS()
- removeClass()
- removeClasseses()
- RemoveClass()
Answer: B) removeClass()
Explanation:
The jQuery method removeClass() is used to remove CSS class to the selected elements.
Discuss this Question
79. Which method is used to set or get the CSS style attribute?
- cssAttribute()
- attribute()
- attr()
- css()
Answer: D) css()
Explanation:
The jQuery method css() is used to get or set the CSS style attribute.
Discuss this Question
80. Which is the correct syntax to get the value of a CSS style attribute/property using the css() method?
- css("propertyname");
- css(propertyname);
- css(".propertyname");
- css("#propertyname");
Answer: A) css("propertyname");
Explanation:
The correct syntax to get the value of a CSS style attribute/property using the css() method is: css("propertyname");
Discuss this Question
81. Which is the correct syntax to set the value of a CSS style attribute/property using the css() method?
- css("propertyname"="value");
- css("propertyname","value");
- css("propertyname":"value");
- css("propertyname":="value");
Answer: B) css("propertyname","value");
Explanation:
The correct syntax to set the value of a CSS style attribute/property using the css() method is:
css("propertyname","value");
Discuss this Question
82. Which is the correct jQuery statement to set background color and text decoration to all <p> elements?
- $("p").css({"background-color": "#f1f1f1"; "text-decoration": "underline"});
- $("#p").css({"background-color": "#f1f1f1"; "text-decoration": "underline"});
- $("p").css({"background-color": "#f1f1f1", "text-decoration": "underline"});
- $("#p").css({"background-color": "#f1f1f1", "text-decoration": "underline"});
Answer: C) $("p").css({"background-color": "#f1f1f1", "text-decoration": "underline"});
Explanation:
The correct jQuery statement to set background color and text decoration to all <p> elements is:
$("p").css({"background-color": "#f1f1f1", "text-decoration": "underline"});
Discuss this Question
83. Which jQuery method is used to get or set the width of an HTML element?
- cssWidth()
- Csswidth()
- lenght()
- width()
Answer: D) width()
Explanation:
The jQuery method width() is used to get or set the width of an HTML element.
Discuss this Question
84. Which jQuery method is used to get or set the height of an HTML element?
- cssHeight()
- CssHeight()
- height()
- getHeight()
Answer: C) height()
Explanation:
The jQuery method height() is used to get or set the height of an HTML element.
Discuss this Question
85. Which jQuery methods are used to get or set the width and height of an HTML element including the paddings?
- innerWidth() and innerHeight()
- width() and height()
- cssWidth() and cssHeight()
- elementWidth() and elementHeight()
Answer: A) innerWidth() and innerHeight()
Explanation:
The jQuery methods innerWidth() and innerHeight() are used to get or set the width and height of an HTML element including the paddings.
Discuss this Question
86. Which jQuery methods are used to get or set the width and height of an HTML element including the paddings and borders?
- outerWidth() and outerHeight()
- width() and height()
- cssWidth() and cssHeight()
- elementWidth() and elementHeight()
Answer: A) outerWidth() and outerHeight()
Explanation:
The jQuery methods outerWidth() and outerHeight() are used to get or set the width and height of an HTML element including the paddings and borders.
Discuss this Question
87. Which are the jQuery methods for traversing up the DOM tree?
- parent()
- parents()
- parentsUntil()
- All of the above
Answer: D) All of the above
Explanation:
These are the jQuery methods for traversing up the DOM tree:
- parent()
- parents()
- parentsUntil()
Discuss this Question
88. Which jQuery method is used to get the direct parent element of the selected element?
- parent()
- parents()
- parentsUntil()
- All of the above
Answer: A) parent()
Explanation:
jQuery method parent() is used to get the direct parent element of the selected element.
Discuss this Question
89. Which jQuery method is used to get the all ancestor elements of the selected element, all the way up to the document's root element (<html>)?
- parent()
- parents()
- parentsUntil()
- All of the above
Answer: B) parents()
Explanation:
jQuery method parents() is used to get the all ancestor elements of the selected element, all the way up to the document's root element (<html>).
Discuss this Question
90. Which jQuery method is used to get the all ancestor elements between two given arguments?
- parent()
- parents()
- parentsUntil()
- All of the above
Answer: C) parentsUntil()
Explanation:
jQuery method parentsUntil() is used to get the all ancestor elements between two given arguments.
Discuss this Question
91. There is a <pre> element, write a jQuery statement to get it's parent?
- $("pre").parent();
- $("pre").parents();
- $("pre").parentsUntil();
- None of the above
Answer: A) $("pre").parent();
Explanation:
The correct jQuery statement to get the direct parent of a <pre> tag is:
$("pre").parent();
Discuss this Question
92. Which are the jQuery methods for traversing down the DOM tree?
- children()
- find()
- childrens()
- Both A. and B.
Answer: D) Both A. and B.
Explanation:
These are the jQuery methods for traversing down the DOM tree:
- children()
- find()
Discuss this Question
93. Which jQuery method is used to get all direct children of the selected element?
- children()
- find()
- childrens()
- Both A. and B.
Answer: A) children()
Explanation:
jQuery method children() is used to get all direct children of the selected element.
Discuss this Question
94. Which jQuery method is used to get descendant elements of the selected element, all the way down to the last descendant?
- children()
- find()
- childrens()
- Both A. and B.
Answer: B) find()
Explanation:
jQuery method find() is used to get descendant elements of the selected element, all the way down to the last descendant.
Discuss this Question
95. What will the following jQuery code do?
$(document).ready(function(){
$("pre").siblings();
});
- It will return all parent elements of <pre> element
- It will return all children elements of <pre> element
- It will return all sibling elements of <pre> element
- It will return all nonrelative elements of <pre> element
Answer: C) It will return all sibling elements of <pre> element
Explanation:
The above code will return all sibling elements of <pre> element.
Discuss this Question
96. Which is the correct jQuery statement to change the color of all <p> elements which are sibling elements of <pre>?
- $("#pre").siblings("p").css({"color": "red"});
- $(".pre").siblings("p").css({"color": "red"});
- $("pre").siblings(".p").css({"color": "red"});
- $("pre").siblings("p").css({"color": "red"});
Answer: D) $("pre").siblings("p").css({"color": "red"});
Explanation:
The correct jQuery statement to change the color of all <p> elements which are sibling elements of <pre> is:
$("pre").siblings("p").css({"color": "red"});
Discuss this Question
97. Which jQuery method is used to get the next sibling element of the selected element?
- sibling()
- nextSibling()
- next()
- siblings()
Answer: C) next()
Explanation:
jQuery method next() is used to get the next sibling element of the selected element.
Discuss this Question
98. Which jQuery method is used to get the all next sibling element of the selected element?
- siblingAll()
- nextSiblingAll()
- nextAll()
- siblingsAll()
Answer: C) nextAll()
Explanation:
jQuery method nextAll() is used to get the all next sibling element of the selected element.
Discuss this Question
99. Let suppose there are multiple <h3> elements in an HTML document, which is the correct jQuery statement to get the first <h3> element?
- $("h3").first();
- $("h3").parent();
- $("h3").firstParent();
- $("h3").top();
Answer: A) $("h3").first();
Explanation:
The correct jQuery statement to get the first <h3> element is:
$("h3").first();
Discuss this Question
100. Let suppose there are multiple <h3> elements in an HTML document, which is the correct jQuery statement to get the last <h3> element?
- $("h3").last();
- $("h3").children();
- $("h3").lastChild();
- $("h3").down();
Answer: A) $("h3").last();
Explanation:
The correct jQuery statement to get the last <h3> element is:
$("h3").last();
Discuss this Question