Home  >  Article  >  Web Front-end  >  Detailed examples of the basic usage of filters in jQuery

Detailed examples of the basic usage of filters in jQuery

小云云
小云云Original
2017-12-26 17:17:591200browse

This article mainly introduces the basic usage of filters in jQuery, and analyzes the related operating techniques of jQuery filters for judging and setting table element attributes in the form of simple examples. Friends who need it can refer to it. I hope it can help everyone. .

The examples in this article describe the basic usage of filters in jQuery. Share it with everyone for your reference, the details are as follows:

HTML text:


##



1111
2222
3333
4444
5555



1111
2222
3333
4444
5555


11111
22222
33333
44444
55555

Javascript operation code:


$('#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");
});

Effect:

##Related recommendations:

Detailed examples of how to create and use vue custom filters

Introduction to filters and custom filters

JQuery, selector /Filter/Performance Optimization

The above is the detailed content of Detailed examples of the basic usage of filters in jQuery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn