有思俱乐部学习园地

css() 方法设置或返回被选元素的一个或多个样式属性。



    使用方式一:返回指定的 CSS 属性的值
    下面的例子将返回首个匹配元素的 background-color 值:
    $('.TestEle').css('background-color');  

    使用方式二:设置指定的 CSS 属性
    下面的例子将为所有匹配元素设置 background-color 值:
    $('.TestEle').css("background-color","Yellow");

    使用方式三:设置多个 CSS 属性
    下面的例子将为所有匹配元素设置 background-color 和 width :
    $('.TestEle').css({"background-color":"Blue" , "width": "100px"});
            

TestEle

TestEle

示例一(可在编辑区域修改):

$('.TestEle').css('background-color');

运行结果展示区域:

工作人员

 
作者: 14互联网G5-2 杨思强
信息录入: 14互联网G5-2 杨思强