Jquery user manual 3-css operations by CHOY

Source: Internet
Author: User
Jquery User Manual

3.: CSS operations

Traditional JavaScript has complicated operations on CSS. For example, the background Syntax of <Div id = "A" style = "Background: Blue"> CSS </div> is document. getelementbyid (""). style. background, while jquery is more convenient for CSS operations, $ ("# "). background (), $ ("# "). background ("red ")
$ ("# A") Get the jquery object [<Div id = ""... /Div>]
$ ("# A"). Background () will retrieve the background style of the object.
$ ("# A"). Background ("red") sets the background style of this object to redjquery. The following methods are provided 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!

<Div id = "A" style = "Background: Blue; color: Red"> CSS </div> <p id = "B"> test </P>

CSS (name) gets 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 <p id = "B" style = "Background: Blue; color: Red"> test </P>, {color: "red", Background: "Blue"}, hash object, color is key, and "red" is value,

CSS (Key, value) is used to set a separate CSS style.
$ ("# B" ).css ("color", "Red"); the final effect is <p id = "B"

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.