1. jQuery样式操作
1.1 操作css方法
- 参数只写属性名,则返回属性值(字符串)
$(this).css('color')
- 参数是 属性名、属性值(逗号分隔,则表示设置属性
$(this).css('color','red')
- 参数可以是对象的形式
$(this).css({
width: 400px,
height: 400px
})
1.2 设置类样式方法
- 添加类
$('button:first').click(function() {
$('div').addClass('block')
})
- 删除类
$('button:first').click(function() {
$('div').removeClass('block')
})
- 切换类
$