The selector can be thought of as an enhanced version of the getElementById method. The getElementById method returns an HTML element, and the jQuery selector returns a wrapper of the HTML element. Using this wrapper set, jQuery gives HTML elements more manipulable methods. In JQuery, one of the core functions is $. Yes, it's just a function with a weird name. This function is the selection function, and its general usage is
var obj=$(selector);
where selector is a string, which is the selector that will be introduced below. What is returned is a wrapped collection of elements. In fact, the power of JQuery's core $ function goes far beyond being used as a selector. When its parameter is a function, its function is similar to the onload event. When the DOM element of the page is completely loaded, the The method will be executed. It has more advantages than onload. onload can only register one function, but it can be called multiple times, that is, multiple functions can be registered to be executed after the DOM is fully loaded, and onload must wait until all content on the page is loaded. If it is executed later, if there are large pictures and other content, it may cause a delay in function execution. The $ function can be executed as long as the DOM structure is fully loaded. Let’s look at a simple example:
I'm a p