文档介绍:jquery
The jQuery library contains the following features:
HTML/DOM manipulation
CSS manipulation
HTML event methods
Effects and animations
AJAX
Utilities
<head><script src="jquery-"></script></head>
http://w3schools./jquery/
2. jquery selectors
Selector
Example
Selects
*
$("*")
All elements
#id
$("#lastname")
The element with id="lastname"
.class
$(".intro")
All elements with class="intro"
.class,.class
$(".intro,.demo")
All elements with the class "intro" or "demo"
element
$("p")
All <p> elements
el1,el2,el3
$("h1,div,p")
All <h1>, <div> and <p> elements
[attribute]
$("[href]")
All elements with a href attribute
[attribute=value]
$("[href='']")
All elements with a href attribute value equal to ""
parent > child
$("div > p")
All <p> elements that are a direct child of a <div> element
parent descendant
$("div p")
All <p> elements that are descendants of a <div> element
2. jquery selectors method
effects
hide() and show()
fadeIn()
fadeOut()
fadeToggle()
fadeTo()
$("button").click(function(){    $("p").hide("slow", function(){        alert("The paragraph is now hidden");    });});
callback:
Chaining:
$("#p1").css("color", "red").slideUp(2000).slideDown(2000);
2. jquery selectors method
jquery HTML
text() - Sets or returns the text content of selected elements
html() - Sets or returns the content of selected elements (including HTML markup)
val() - Sets or returns the value of form fields
attr() method is also used to set/change attribute values.
append() - Inserts content at the end of the selected elements
prepend() - Inserts content at the beginning of the selected elements
after() - Inserts content after the selected elements
before() - Inserts content before the selected elements
remove() - Removes the selected element (and its child elements)
empty() - Removes the child elements from the selected element
addClass() - Adds one or more classes t