JQuery knowledge point sorting, jquery knowledge point
SlideUp (); slide up // change the attribute of the element height until the height is 0 to hide the element
SlideDown ();
SlideToggle ();
FadeOut (); Fade Out // transparent
FadeIn ()
Copy codeThe Code is as follows:
Function (){
$ ("Span. Italian"). toggle ();
$ ("Span. Italian"). toggle ();}
Add two toggle functions to a function to implement language switching.
You can apply multiple such selectors to an element at the same time.
Put the script tag at the bottom, only before </body>, because the script will cause a problem, they will block parallel download in the browser. Multiple images on different servers can be downloaded at the same time. Once the browser encounters a <script> flag, it cannot download Multiple Elements in parallel.
Put the following to improve the download speed
Var msg = "high score: <strong>" + pts + "</strong>"
// You can add html tags to variables.
Var discount = Math. floor (Math. random () * 5) + 5); // outputs a number between 5 and 10.
// Math. random (); returns a random number ranging from 0 to 1.
// Math. floor (x); returns the largest integer smaller than x.
Var discount_msg = "<p> Your Discount is" + discount + "% <p> ";
Alert (discount); // pop-up information
$ ("P"). append ("<strong> 123 </strong> ");
If <p> qwert </p>
<P> qwert <strong> 123 </strong> </p>
Jquery variable name requirements
It cannot start with a number, be case sensitive, have no mathematical operators, and cannot contain spaces or punctuation marks. It can be underlined,
$ (*) Select each element on the page
$ (". Guess_box"). click (function (){
$ (This). append ("hahaha ");
})
// When multiple elements hold the same class, you can use $ (this) to call the object of the current execution method when I only want to process the elements of my current operation.
Copy codeThe Code is as follows:
<Ol>
<Li> 1 </li>
<Li> 2 </li>
</Ol>
$ ("# BtnRemove"). click (function (){
$ ("Li"). remove ();
});
$ ("Li"). remove ();
Jquery descendant Selector
Copy codeThe Code is as follows:
$ ("Div p") Select All section elements under the div
$ ("Div") Select All div elements under the div
$ ("Div img") Select All img elements under the div
Bind events in two ways
Copy codeThe Code is as follows:
$ ("# MyElement"). click (function (){
Alert ("click ");
});
$ ("# MyElement"). bind ('click', function (){
Alert ("click ");
});
Onblur (); lost focus
Onchange ()
// Trigger a method if the Element Content Changes
Copy codeThe Code is as follows:
<Html>
<Head>
<Script type = "text/javascript">
Function upperCase (x)
{
Var y = document. getElementById (x). value
Document. getElementById (x). value = y. toUpperCase ()
}
</Script>
</Head>
<Body>
Enter your name:
<Input type = "text" id = "fname" onchange = "upperCase (this. id)"/>
</Body>
</Html>