JQuery user manual. You can read it patiently and get started. 3.
:CSS operations
Traditional javascript has complicated operations on css, such
Css
The background syntax is document. getElementById (""). style. background, while jQuery is more convenient for css operations, $ ("# "). background (), $ ("# "). background ("red ")
$ ("# A") Get the jQuery object [
]
$ ("# A"). background () will retrieve the background style of the object.
$ ("# A"). background ("red") sets the background style of this object to redJQuery provides the following methods to operate css
Background () background (val) color (val) css (name) css (prop)
Css (key, value) float (val) height (val) width (val)
Left () left (val) overflow (val) position (val) top (val)
Here we need to explain the css (name) css (prop) css (key, value). What do other users know about the functions of their names!<PId= ""Style= "Background: blue; color: red">Css P> <PId= "B">Test P>
Css (name)Get the style named name
$ ("# A" ).css ("color") will get the color value red in the style, ("# a" ).css ("background") will get the blue
Css (prop)Prop is a hash object used to set a large number of css styles.
$ ("# B" ).css ({color: "red", background: "blue "});
The final result is
Test
, {Color: "red", background: "blue"}, hash object, color as key, and "red" as value,
Css (key, value)Used to set a separate css style
$ ("# B" ).css ("color", "red"); the final effect is
Test