jQuery中过滤器的基本用法示例

本文实例讲述了jQuery中过滤器的基本用法。分享给大家供大家参考,具体如下:

HTML正文:



1111
2222
3333
4444
5555



1111
2222
3333
4444
5555


11111
22222
33333
44444
55555

Javascript操作代码:

$('#b1').click(function(){
/*table:eq(0) tr:even table:eq(0):筛选出第一张表格 tr:even:筛选出tr属性的对象
*注意table和tr对象中间有空格,表示从属关系
*/
$('table:eq(0) tr:even').css("background","red"); 
});
$('#b2').click(function(){
$('table:eq(0) tr:odd').css("background","green");
});
$('#b3').click(function(){
$('table:eq(1) td:even').css("background","red");
});
$('#b4').click(function(){
$('table:eq(1) td:odd').css("background","green");
});
$('#b5').click(function(){
$('table:eq(2) td:even').css("background","green");
});

效果:

jQuery中过滤器的基本用法示例_第1张图片

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery表格(table)操作技巧汇总》、《jQuery表单操作总结》、《jQuery常用插件及用法总结》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。

你可能感兴趣的:(jQuery中过滤器的基本用法示例)