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