jquery 操作css 类 (新增和删除)
表格奇偶行数 显示不同的class 并设置mouseover 的add class发光属性
$(document).ready(function(){
$(".table tr").mouseover(function(){
$(this).addClass("odd");
}).mouseout(function(){ $(this).removeClass("odd");//移除该行的class });
$(".table tr:even").addClass("even"); //tr:even 是代表表格里的偶数行
});
jQuery 操作 CSS
jQuery 拥有若干进行 CSS 操作的方法。我们将学习下面这些:
- addClass() - 向被选元素添加一个或多个类
- removeClass() - 从被选元素删除一个或多个类
- toggleClass() - 对被选元素进行添加/删除类的切换操作
- css() - 设置或返回样式属性
jQuery 尺寸 方法
jQuery 提供多个处理尺寸的重要方法:
- width()
- height()
- innerWidth()
- innerHeight()
- outerWidth()
- outerHeight()
其中 : outerWidth() = width(100) + padding(10*2) + border(1*2) = 122
outerWidth(true) = width(100) + padding(10*2) + border(1*2)+ margin(5*2) = 122
innerHeight() = width(100) - padding(10*2) - border(1*2)

浙公网安备 33010602011771号