这次给大家带来jquery表格进行操作有有哪些技巧,jquery表格进行操作的注意事项有哪些,下面就是实战案例,一起来看一下。
1、表格奇数行和偶数行分别添加样式
$(function(){
$('tr:odd').addclass(odd);
$('tr:even').addclass(even);
});
不算表的头部
$(function(){
$('tbody>tr:odd').addclass(odd);
$('tbody>tr:even').addclass(even);
});
2、单选框控制行的高亮
$('tobdy>tr').click(function(){
$(this).addclass('selected')
.siblings().removeclass('selected')
.end() // 重新返回该
对象
.find(':radio').attr('checked',true);
});
3、复选框控制行的高亮显示
$('tobdy>tr').click(function(){
if( $(this).hasclass('selected') ){ // 判断是否有selected高亮样式
$(this).removeclass('selected')
.find(':checkbox').attr('checked',false);
}else{
$(this).addclass('selected')
.find(':checkbox').attr('checked',true);
}
});
4、表格内容筛选
$(function(){
$('table tbody tr').hide()
.filter(:contains(李)).show();
});
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
jquery动态操作表行并对新行添加事件
jquery实现分章节锚点回到顶部效果以上就是jquery表格进行操作有有哪些技巧的详细内容。
