What is $ () in the 1.jQuery library? (The answer is as follows)
The $ () function is a nickname for the jquery () function, and the $ () function is used to wrap any object into a jquery object, and then you are allowed to invoke several different methods defined on the jquery object. You can even pass a selector string to the $ () function, which returns a JQuery object that contains an array of all matching DOM elements.
2.$ (document). What is the function of ready ()? Why do you use it?
The Ready () function is used to execute code when a document enters the ready state. jquery allows you to execute code when the DOM is fully loaded (for example, when the HTML is fully parsed by the DOM tree when the build is complete). The biggest benefit of using the $ (document). Ready () is that it works with all browsers, and jquery helps you solve cross-browser challenges.
What is the difference between the 3.JavaScript window.onload event and the JQuery ready function?
The main difference between the JavaScript window.onload event and the JQuery ready function is that the former waits for the DOM to be created and waits until all external resources, including large pictures, audio, and video, are fully loaded. If loading pictures and media content takes a lot of time, the user will feel that the code defined on the Window.onload event has a noticeable delay when it executes.
On the other hand, the jQuery ready () function simply waits on the DOM tree, without waiting for the image or external resources to load, thus executing faster. Another advantage of using JQuery $ (document) is that you can use it more than once in a Web page, and the browser executes them in the order in which they appear in the HTML page, whereas the onload technique can only be used in a single function. Given this benefit, using the jQuery ready () function is better than using JavaScript window.onload events.
What is the difference between the 4.$ (this) and the This keyword in jQuery?
$ (this) returns a JQuery object, which you can invoke with multiple jquery methods, such as text (), get the value in Val (), and so on.
this represents the current element, which is one of the JavaScript keywords that represents the current DOM element in the context. You cannot call the JQuery method on it until it is wrapped by the $ () function, for example $ (this).
What is the difference between the detach () and the Remove () methods in 5.jQuery?
Although the detach () and remove () methods are used to remove a DOM element, the main difference between the two is that detach () keeps track of the elements that were removed from the past, so it can be canceled, and the Remove () method maintains a reference to the object that was previously deleted.
6. What are the main advantages of using a CDN to load the JQuery library?
In addition to the many benefits of error saving server bandwidth and faster download speed, most importantly, if the browser has downloaded the same version of JQuery from the same CDN, then it will not download it again.
7. What is the difference between the Jquery.get () and the Jquery.ajax () methods?
The Ajax () method is more powerful and more configurable, allowing you to specify how long to wait and how to handle errors. The Get () method is a specialized method that only gets some data.
What is the method chain in 8.jQuery? What are the benefits of using a method chain?
The method chain is calling another method on the result returned by one method, which makes the code straightforward and performs better with a single round of lookups for the DOM.
9. What happens if you return false in a JQuery event handler?
This is typically used to prevent events from bubbling up.
10. Which method is more efficient: document.getElementById ("MyId") or $ ("#myId")?
First, because it calls the JavaScript engine directly.
jquery Face Questions