First, how to add jQuery to the Web page
The <script> tag should be located in the
< Head > < src= "Jquery.js"></script></ Head>
In HTML5, because JavaScript is the default scripting language in HTML5 and all modern browsers! <script> tags do not need to use type= "Text/javascript", of course, if not, or add better ~
< Head > < src= "Jquery.js" type= "Text/javascript"></script> </ Head >
Jquery.js need to download the current website, it is best to download the latest version
Second, jquery syntax
The jQuery syntax is for the selection of HTML elements, and you can perform certain operations on elements.
The underlying syntax is: $ (selector). Action ()
- Dollar sign definition JQuery
- Selector (selector) "Query" and "find" HTML elements
- JQuery Action () performs an operation on an element
Example: Demonstrating the jQuery hide () function
$ (this). Hide ()-hides the current element
$ ("P"). Hide ()-Hides all paragraphs
$ (". Test"). Hide ()-hides all elements of class= "test"
$ ("#test"). Hide ()-hides all elements of the id= "test"
Example: hiding an element that id= "text"
<script type= "Text/javascript" > $ (document). Ready (function () { $ ("button"). Click (function () { $ ("#button"). Hide (); }); </script>
<id= "text"> This is a text that will be hidden after a click. </ P > < type= "button"> Buttons </button>
All JQuery functions are in a document ready function:
$ (document). Ready (function () {---jQuery functions go----});
This is to prevent the document from running JQuery code before it is fully loaded (ready).
[2016-10-24]jquery Study Review Note 1.0