Getting Started with jquery
before learning jquery, look at HTML, CSS, JavaScript.
jquery is a library of JavaScript functions
Mainly include:
1.HTML element Extraction
2.HTML element operation
3.CSS operation
4.JavaScript Effects and animations
5.HTML DOM Traversal and modification
6.AJAX
7.Utilities
First, how to use jquery in HTML
Add a script tag to the head in the page
<script type= "Text/javascript" src= "Jquery.js" ></script>
<script type= "Text/javascript" src= "Jquery.js" ></script>
Second, the most distinctive features of jquery
$ is one of the obvious features of jquery. Its basic usage: $ (selector). Action ()
(1) selector a bit like DOM parsing.
(2) Action is the response event.
Third, jquery selector
(1) using CSS to extract HTML elements
Extract tags for all "p" in HTML: $ ("P")
Extract the label for "P" in a class in HTML: $ ("P.class")
Extract the first tag with "P" in the HTML ID as Demo: # ("P#demo")
(2) using XPath to extract the elements of a given property
$ ("[href]") selects all elements with an href attribute.
$ ("[href= ' # ']") selects all elements with an HREF value equal to "#".
$ ("[href!= ' # ']") selects all elements with an HREF value that is not equal to "#".
$ ("[href$= '. jpg ']") selects all elements with an href value ending with ". jpg".
Iv. Responding to Events
$ ("label"). Click (function () {... some code ...})
(1) in the head of the HTML
<script type= "Text/javascript" src= "Jquery.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("button"). Click (function () {
... some code ...
});
});
</script>
(2) in a separate JS
<script type= "Text/javascript" src= "Jquery.js" ></script>
<script type= "Text/javascript" src= "My_jquery_functions.js" ></script>
Note: jquery name conflicts
jquery uses the $ symbol as a way to profile jquery.
functions in some other JavaScript libraries, such as Prototype, also use the $ notation.
JQuery uses a method called noconflict () to resolve the problem.
var jq=jquery.noconflict (), which helps you to use your own name (such as JQ) instead of the $ symbol.
V. Event functions
Common events: Hide, show, toggle, swipe, and animate
Getting Started with jquery