jquery Learning Notes

Source: Internet
Author: User

1. All P elements are found, and the elements must be child elements of the DIV element.

$ ("div > P");

2. Setting the page background color

$ (document.body). CSS ("Background", "Black");

3. Hides all elements in a form.

$ (myform.elements). Hide ();

4. In the first form of the document, look for all the radio buttons (that is, the input element with the type value radio).

$ ("Input:radio", Document.forms[0]);

5. In an XML document returned by AJAX, look for all div elements.

$ ("div", xml.responsexml);

6. Dynamically create a DIV element (and all of its contents) and append it to the BODY element.

$ ("<div><p>Hello</p></div>"). AppendTo ("body");

7. Create a <input> element must also set the Type property. Because Microsoft specifies that the type of the <input> element can only be written once.

Not valid in IE:

$ ("<input>"). attr ("type", "checkbox");

Valid in IE:

$ ("<input type= ' checkbox ' >");

8. Dynamically create a DIV element (and all of its contents) and append it to the BODY element.

$ ("<div>", {
"Class": "Test",
Text: "Click me!",
Click:function () {
$ (this). Toggleclass ("test");
}
}). AppendTo ("body");

jquery Learning Notes

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.