Self-study notes for jquery beginners (1)

Source: Internet
Author: User

1. Return the specified HTML Value
$ ("# MSG" cmd.html (); // value, equivalent to the get Method
$ ("# MSG" ).html ("hello"); // value assignment, equivalent to the Set Method
2.

$. Get ("search. Do", {ID: 1}, rend );
Function rend (XML ){
Alert (XML );
}

$ ("# MSG"). ajaxstart (function (){
This.html ("loading ..... ");
});

$ ("# MSG"). ajaxsuccess (function (){
This.html ("Loading completed! ");
});

3.

$ ("# MSG"). Show ("fast ");
$ ("# MSG"). Hide ("slow ");
$ ("# MSG"). fadein ();
$ ("# MSG"). fadeout ();

$ ("Input: Radio", document. Forms [0]);
4. Create span: $ ("<SPAN/> ");
$ ("<Div> <p> jquery </P> </div>"). appendto ("body ");
5. Create a checkbox
$ ("<Input type = 'checkbox'> ");
6. Set the page background color
((Docuemtn.body).css ("background", "Red ");
7. Hide all elements in a form
$ (Myform. Elements). Hide ();
$ (Document). Ready ();

Jquery (function ($ )){
};

8. The Reverse Method Reverse the Array
$ ("IMG"). Reverse ();
9. Obtain the first element.
$ ("IMG"). Get (0 );

$ ("Div"). Index ($ ("# foobar") [0]);

10. Specify the src attribute of
$ ("IMG"). Each (function (I ){
This. sec = "test" + I + ". jpg ";
});
11. Get the jquery object and use the $ (this) function.
$ ("IMG"). Each (function (){
$ (This). toggleclass ("example ");
});

12. Length attribute
// Number of elements in the jquery object
$ ("IMG"). length;

13. Size () method
// Number of elements in the jquery object
$ ("IMG"). Size ();

14. extended two functions: min and Max
Jquery. Extend ({
Min: function (a, B) {return a <B? A: B },
MAX: function (a, B) {return A> B? A: B}
})
15. match all elements
$ ("*");
16. Find all class styles that are "youclass" Elements
$ (". Youclass ");
17. match all elements based on the specified element name
$ ("Div ");
18. match an element based on the given ID
$ ("# Firstdiv ");
19. Find the elements matching any class
$ ("Div, span, P. youclass ");
20. match all descendant elements under the given ancestor element [match both son and grandson]
$ ("Form input ");
21. match all child elements under a given parent element [only match son, not grandson]
$ ("Form> input ");
22. match all input elements following the label.
$ ("Label + input ");
23. match all input elements of the same generation with the form
$ ("Form ~ Input ");
24. match an element with a given index value and search for the second row
$ ("TR: eq (1 )");
25. match all the elements with an even index value and count from 0.
$ ("TR: Even ");
26. Match the first element found
$ ("TR: First ");
27. match all elements greater than the given index value
$ ("TR: GT (0 )");
28. Match title elements such as H1, H2, H3, and add the background color to all titles on the page.
$ (": Header" ).css ("background", "# ff0000 ");
29. Match the last element found
$ ("TR: Last ");
30. match all elements smaller than the given index value
$ ("TR: Lt (2 )");
31. Remove all elements that match the given Selector
$ ("Input: Not (: checked )");
32. match all elements whose index values are base, and count from 0
$ ("TR: odd ");
33. Match the elements that contain the given text
$ ("Div: Contains ('Tom ')");
34. Match All null elements that do not contain child elements or text
$ ("TD: empty ");
35. Match elements containing child elements or text
$ ("TD: parent ");
36. match all invisible elements
$ ("TR: hidden ");
37. match all visible elements
$ ("TR: visible ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.