?
This document uses PHP Chinese website manual Release
訪問(wèn)匹配元素的樣式屬性。
jQuery 1.8中,當(dāng)你使用CSS屬性在css()或animate()中,我們將根據(jù)瀏覽器自動(dòng)加上前綴(在適當(dāng)?shù)臅r(shí)候),比如("user-select", "none"); 在Chrome/Safari瀏覽器中我們將設(shè)置為"-webkit-user-select", Firefox會(huì)使用"-moz-user-select", IE10將使用"-ms-user-select".
要訪問(wèn)的屬性名稱
一個(gè)或多個(gè)CSS屬性組成的一個(gè)數(shù)組
要設(shè)置為樣式屬性的名/值對(duì)
屬性名,屬性值
1:屬性名
2:此函數(shù)返回要設(shè)置的屬性值。接受兩個(gè)參數(shù),index為元素在對(duì)象集合中的索引位置,value是原先的屬性值。
取得第一個(gè)段落的color樣式屬性的值。
$("p").css("color");
將所有段落的字體顏色設(shè)為紅色并且背景為藍(lán)色。
$("p").css({ "color": "#ff0011", "background": "blue" });
將所有段落字體設(shè)為紅色
$("p").css("color","red");
逐漸增加div的大小
$("div").click(function() { $(this).css({ width: function(index, value) { return parseFloat(value) * 1.2; }, height: function(index, value) { return parseFloat(value) * 1.2; } }); });