阅读(2305) (0)

jQuery 样式控制

2017-07-21 17:37:21 更新
.css()
获取或设置指定的 css 样式:
$('body').css('background-color');
$('body').css('background-color', 'red');
$('body').css('background-color', function(index, value){return value + '1'});
$('body').css({color: 'green', 'background-color': 'red'});
.width() .height()
获取或设置元素的宽和高
$('body').width();
$('body').width(50);
$('body').width(function(index, value){return value += 10});
.innerWidth() .innerHeight() .outerHeight() .outerWidth()
元素的其它尺寸值
.scrollLeft() .scrollTop()
获取或设置滚动条的位置
.offset() .position()
获取元素的坐标。 offset 是相对于 document , position 是相对于父级元素