I. Summary
This chapter explains the knowledge of the most important selector parts of jquery. With the jquery selector we can get almost any one or a group of objects on the page, which can significantly reduce the developer's workload.
Two. Foreword
To write any JavaScript program we want to get the object first, the jquery selector can completely change the way we usually get the object and get almost any semantic object, such as "owning the title property and the <a> element containing the test in the value." The only way to do this is to write a jquery selector string. Learning the jquery selector is the most important step in learning jquery.
Three. Dom objects and jquery wrapper sets
Whether you're writing a program or looking at an API document, we should always be careful to differentiate between DOM objects and jquery wrapper sets.
1.Dom objects
In traditional JavaScript development, we all get DOM objects first, such as:
var div = document.getElementById("testDiv");
var divs = document.getElementsByTagName("div");
We often use the document.getElementById method to get a single Dom object from an ID, or we use the document.getElementsByTagName method to get a collection of Dom objects based on the HTML tag name.
Additionally, in an event function, you can use this reference event to trigger an object in a method function (but there is a problem with IE6 in the multicast event function), or use the event object's target (FF) or srcelement (iIE6) to get to the DOM object that raised the event.
Notice what we get here are DOM objects, and Dom objects have different types such as input, Div, span, and so on. Dom objects have only a limited number of properties and methods:
2.jQuery Packing Set
The jquery wrapper set can be said to be an extension of the DOM object. In the jquery world, all objects, whether one or a group, are encapsulated into a jquery wrapper set, such as a jquery wrapper set containing an element:
var jQueryObject = $("#testDiv");
The jquery wrapper set is called together as an object. The jquery wrapper set has rich properties and methods that are unique to jquery: