返回值:jQuerycss(name, function(index, value))
概述
在所有匹配的元素中,設(shè)置一個(gè)樣式屬性的值。
數(shù)字將自動(dòng)轉(zhuǎn)化為像素值
參數(shù)
namevalue
屬性名
function(index, value)Function
此函數(shù)返回要設(shè)置的屬性值。接受兩個(gè)參數(shù),index為元素在對(duì)象集合中的索引位置,value是原先的屬性值。
示例
描述:
逐漸增加div的大小
jQuery 代碼:
$("div").click(function() {
$(this).css({
width: function(index, value) {
return parseFloat(value) * 1.2;
},
height: function(index, value) {
return parseFloat(value) * 1.2;
}
});
});