jQuery is an open-source, fast, and feature-rich JavaScript library that was designed for simplifying HTML DOM tree traversal and manipulation, moreover, it also simplifies event handling, CSS Animation, and Ajax. jQuery has drastically changed the way programmers write JavaScript code.
Question 1: Which of the following correctly describes jQuery?
A) JavaScript method
B) JavaScript library
C) Both A and B
D) JSON library
Answer: JavaScript library
Explanation: jQuery is an open-source cross-platform JavaScript library that is designed for simplifying the client-side scripting of HTML.
Question 2: Which of the following sign is used for the shortcut for jQuery?
A) %
B) $
C) &
D) None of these
Answer: $
Explanation: Every selector in jQuery starts with $(). Another name for this sign is Factory Function.
Question 3: Name Conflicts in jQuery are handled using which method?
A) conflict()
B) noConflict()
C) nameConflict()
D) None of these
Answer: noConflict()
Explanation: Consider a case where two different frameworks use the same alias, here a conflict could occur. noConflict() method can handle such situations. It releases the hold on $ identifier so that other libraries can use it.
Question 4: In order to attach a handler to an event, which of the following jQuery method can be used?
A) bind()
B) attach()
C) Both of these
D) None of these()
Answer: bind()
Explanation: The bind() method in jQuery is used to attach one or more event handlers for selected elements from a set of elements. It specifies which function to run when the event occurs.
Question 5: In order to perform asynchronous HTTP requests, which of the following jQuery method can be used?
A) ajaxSync()
B) ajaxSetup()
C) ajax()
D) None of these
Answer: ajax()
Explanation: The ajax() method is used to perform asynchronous HTTP requests in jQuery. It sends asynchronous HTTP requests to the server. AJAX acronym means Asynchronous JavaScript and XML.
Question 6: In order to set the value of an element, which of the following method can be used?
A) val()
B) setVal()
C) setValue()
D) None of these
Answer: val()
Explanation: Following are the uses of the val() method:
Set the value of every matched element.
Get the current value of the first element in the set of matched elements.
Question 7: Which of the following jQuery method is used to load data using HTTP get?
A) post(URL, data, callback, dataType)
B) get(URL, data, callback, dataType)
C) Both of these
D) None of these
Answer: get(URL, data, callback, dataType)
Explanation: It is an internal method of jQuery. It is used to load data using HTTP get requests. It returns XMLHttpRequest object
Question 8: Which method can be used to remove all the child nodes from the set of matched elements?
A) delete()
B) empty()
C) remove()
D) None of these
Answer: empty()
Explanation: The empty() method can be used to remove all the child nodes from the set of matched elements.
Question 9: If two variables share the common name then which of the following is going to take precedence?
A) Local Variable
B) Global Variable
C) Both of these will have the same precedence
D) None of these
Answer: Local Variable
Explanation: If two variables share the common name then the Local Variable is going to take precedence. In case a local and global variable shares a common name, the local variable hides the global variable.
Question 10: Which of the following takes selector as an argument and returns true if any selected element matches the specified selector?
A) is()
B) index()
C) each()
D) None of these
Answer: is()
Explanation: The is() method takes the selector as an argument and returns true if any selected element matches the specified selector.