1. $() can be $(expression), which is a css selector, Xpath or html element, that is, the target element is matched through the above expression.
For example: the object constructed by $("a") uses a CSS selector to construct a jQuery object - it selects all tags. For example:
$("a").click(function(){...})
is an event triggered when any link on the page is clicked. To be precise, jQuery constructs an object $("a") using the tag , and the function click() is an (event) method of this jQuery object.
For example, there is this piece of HTML code:
Hello
in the full text, and display
3. $() can be $(function), which is a shorthand for $(document).ready(). The common form is like this:
$ (document).ready(function(){
alert("Hello world!");
});
Variable operation:
$(function(){
alert(" Hello world!");
});
For selecting elements in HTML documents, jQuery has two methods:
1) Such as $("div>ul a"), its It means the a tag in the ul tag in the div tag
However, there is a difference between $('div>ul') and $('div ul'),
$(' div>ul') looks for