HTML Questions & Answers – Essential JavaScript and jQuery – 2

This set of HTML Multiple Choice Questions & Answers (MCQs) focuses on “Essential JavaScript and jQuery – 2”.

1. jQuery does not contain the _____________ feature.
a) AJAAX
b) AJAX
c) CSS manipulation
d) Effects and animations
View Answer

Answer: a
Explanation: jQuery contains many features like CSS manipulation, AJAX, Effects, and animations, Utilities, HTML event methods, HTML/DOM manipulation. There are also jQuery plugins for every given task. jQuery simplifies complicated things in JavaScript.

2. What is the correct syntax of jQuery?
a) action().$(selector)
b) $(selector).action()
c) (selector)$.action()
d) action().(selector)$
View Answer

Answer: b
Explanation: The basic syntax of jQuery is $(selector).action(), $ sign defines access of jQuery, (selector) is HTML element, action() is for the jQuery action that is to be performed. E.g. $(“h1”).hide(), this will hide all the <h1> elements.

3. In jQuery all the elements are selected by writing ____________
a) $(this)
b) $(“:button”)
c) $(“*”)
d) $(“.class_name”)
View Answer

Answer: c
Explanation: In jQuery all the elments are selected by writing $(“*”). $(this) helps in selecting current HTML element. All the button elements are selected by writing $(“:button”). If we want to select a specific class we should write $(“.class_name”).
advertisement
advertisement

4. Which of the following is not event method in jQuery?
a) click()
b) mouseenter()
c) mousedown()
d) hide()
View Answer

Answer: d
Explanation: The actions that can be performed on the web page are called events. Some common DOM events are blur(), click(), bilnd(), change(), dbclick(), eroor(), delegate(), die(), event.data, event.currentTarget, event.pageX, mouseenter(), mousedown(), event.result, event.target, focus(), hover(), keydown(), focusout(), live(), load(), keyup() etc.

5. hover() method is the combination of ____________
a) mouseleave() and mouseeneter()
b) mousedown() and mouseenter()
c) mouseup() and mousedown()
d) mouseleave() and mousedown()
View Answer

Answer: a
Explanation: hover() method is the combination of mouseleave() and mouseenter(). It takes two functions. When the mouse leaves HTML element then mouseleave() function is called and when mouse enters HTML element then mouseenter() function is called.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Which of the following is not the fade method in jQuery?
a) fadeTo()
b) fadeOn()
c) fadeOut()
d) fadeIn()
View Answer

Answer: b
Explanation: jQuery has various fade methods including fadeout(), fadeTo(), fadeToggle(), fadeIn().
The syntax of fadeIn() is $(selector).fadeIn(speed,callback);
For fadeout() we use $(selector).fadeOut(speed,callback);
For fadeToggle we use $(slecetor).fadeToggle(speed,callback);
For fadeTo() syntax is $(selector).fadeTo(speed,opacity,callback).

7. Which of the following is not the sliding method in jQuery?
a) slideToggle()
b) slideDown()
c) slideUp()
d) slideIn()
View Answer

Answer: d
Explanation: jQuery have three slide methods namely slideUp(), slideDown() and slideToggle().
Syntax for slideDown() is $(selector).slideDown(speed,callback);
For slideUp() we use $(selector).slideUp(speed,callback).
For slideToggle() method the syntax is $(selector).slideToggle(speed,callback).
advertisement

8. Which of the following is not the jQuery method for manipulation?
a) stop()
b) html()
c) text()
d) val()
View Answer

Answer: a
Explanation: For attributes manipulation we use three methods named html(), text() and val(). The content of selected elements is returned by html(). The text content of selected elements is returned by text(). The values of form fields is returned by val().

9. The method not used to add new content is ___________
a) after()
b) prepend()
c) before()
d) add()
View Answer

Answer: d
Explanation: In jQuery there are four methods to add new content namely prepend(), before(), after(), append(). The append() method inserts at the end, prepend() method inserts at the beginning of the content, after() method inserts the content after selected HTML element, befor() inserts before the selected HTML element.
advertisement

10. Which method is not used for CSS manipulation?
a) toggleClass()
b) removeClass()
c) beforeClass()
d) css()
View Answer

Answer: c
Explanation: There are several functions for CSS manipulation. Some of them are css(), removeClass(), toggleClass(), addClass(). The style attribute is returned by css() method. Classes are added by addClass() method. Classes are removed by removeClass() method. The toggling between adding and removing classes is achieved by toggleClass() method.

11. Which of the following is not a jQuery dimension method?
a) innerWidth()
b) outerHeight()
c) height()
d) css()
View Answer

Answer: d
Explanation: There are various important methods for dimension. Some of them are height(), innerHeight(), outerWidth(), outerHeight(), width(), innerWidth(). Width() method includes border, margin and padding. innerWidth() and innerHeight() method includes padding. outerHeight() and outerWidth() method includes border and padding. CSS() method is used for CSS manipulation in jQuery.

12. Which method is not used for traversing DOM tree?
a) parent()
b) parentsUntil()
c) parents()
d) after()
View Answer

Answer: d
Explanation: There are three methods for the traversal of DOM tree. Parent(), parentsUntil(), parents(). Direct parent element is returned by parent() method. All the ancestor elements are returned by parents() method. All the ancestor elements that are between given two arguments are returned by parentsUntil() method.

13. Which method is not for traversing DOM tree sideways?
a) parent()
b) siblings()
c) prev()
d) nextAll()
View Answer

Answer: a
Explanation: There are methods for traversing DOM tree sideways. Some of them are next(), prev(), prevAll(), nextAll(), siblings(), prevUntil(), next(). All the sibling elements are returned by siblings() method. The next sibling is returned by next() method. All the next siblings are returned by nextAll() method.

14. Which method is not used for filtering in jQuery?
a) next()
b) first()
c) eq()
d) last()
View Answer

Answer: a
Explanation: The basic filtering methods are eq(), not(), filter(), last() and first(). The first element is returned by first() method, last element is returned by last() method, the specific index number of element is returned by eq() method.

15. AJAX is not used in _____________
a) Gmail
b) Youtube
c) Facebook
d) Yahoo
View Answer

Answer: d
Explanation: AJAX stands for Asynchronous JavaScript and XML. AJAX loads data in the background and then displays it on the webpage. The application of AJAX is on Gmail, Youtube, Facebook and Google Maps tabs. Several methods for AJAX functionality is provided by jQuery.

Sanfoundry Global Education & Learning Series – HTML.

To practice all areas of HTML, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.