AJax技术

css() Method

字号+ 作者:H5之家 来源:H5之家 2017-03-24 13:01 我要评论( )

Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, and XML.

jQuery - css() Method

Previous Next Chapter

jQuery css() Method

The css() method sets or returns one or more style properties for the selected elements.

Return a CSS Property

To return the value of a specified CSS property, use the following syntax:

css("propertyname");

The following example will return the background-color value of the FIRST matched element:

Example

$("p").css("background-color");

Try it Yourself »

Set a CSS Property

To set a specified CSS property, use the following syntax:

css("propertyname","value");

The following example will set the background-color value for ALL matched elements:

Example

$("p").css("background-color", "yellow");

Try it Yourself »

Set Multiple CSS Properties

To set multiple CSS properties, use the following syntax:

css({"propertyname":"value","propertyname":"value",...});

The following example will set a background-color and a font-size for ALL matched elements:

Example

$("p").css({"background-color": "yellow", "font-size": "200%"});

Try it Yourself »

Test Yourself with Exercises!

Exercise 1 »  Exercise 2 »  Exercise 3 »  Exercise 4 »

jQuery CSS Reference

For a complete overview of all jQuery CSS methods, please go to our jQuery HTML/CSS Reference.


Previous Next Chapter

Sponsored Links


2016-2017 W3ii.com. All Rights Reserved. Email: jacklee8902@gmail.com



 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • jQuery Get Started

    jQuery Get Started

    2017-03-24 12:03

  • AJAX PHP Example

    AJAX PHP Example

    2017-03-24 10:00

  • JavaScript学习指南下载 PDF高清版

    JavaScript学习指南下载 PDF高清版

    2017-03-23 10:04

  • 轻松理解JavaScript之AJAX

    轻松理解JavaScript之AJAX

    2017-03-20 13:03

网友点评
n