JQuery operation table (line coloring, highlighting, and filtering data) _ jquery-js tutorial

Source: Internet
Author: User
Recently, many table operations have been performed in the project. In the past, when we were doing some results, we often realized it through program code. This effort is not worth it, because JQuery can be fully implemented and the client runs without being processed by the server, quick Response to users, reduced server pressure, checked some information, and wrote four demos:

1. interlace coloring

The Code is as follows:


$ ('# Table1 tr: odd'). addClass ('odd ');
$ ('# Table1 tr: even'). addClass ('even ');


Effect:

2. Highlight rows containing specific data

The Code is as follows:


$ ("# Table2 tr: contains ('fuck')"). addClass ("selected ");


3. filter data

The Code is as follows:


$ ("# Filter"). click (
Function (){
$ ("# Table3. datarow"). hide (). filter (": contains ('abcdefg')"). show ();
}
);


4. filter data instantly based on user input

The Code is as follows:


$ ("# Keyword"). keyup (function (){
$ ("# Table3. datarow "). hide (). filter (": contains ('" + ($ (this ). val () + "')"). show ();
}). Keyup ();


Before Filtering:

Input ck:



Online Demo http://demo.jb51.net/js/2012/JQueryTableExample/
Package and download JQueryTableExample_Edi.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.