Set core JS codes of different colors for table parity rows

Source: Internet
Author: User

Set core JS codes of different colors for table parity rows

It is useful to set different colors for table parity rows in some cases. The following is a good example. You can refer to it for help.

This is a more practical function. The experience of reading table data is obviously better when the color of the parity row is set to different. Otherwise, the data will appear very complicated and crowded (especially when there are many rows of table data ). You will have a strong experience only when you are actually engaged in this aspect. I have just experienced it. Please stay here for your reference ~

 

The core JS script code is as follows (the id of the table element is adjusted according to your own situation, the jquery-1.7.min.js in the code can be downloaded on the jquery official website)

The Code is as follows:

<Script src = "jquery-1.7.min.js"> </script>

<Script>

$ (Document). ready (function (){

SetTableRowColor ();

 

});

// Use CSS to control the color of the even row

Function SetTableRowColor ()

{

 

$ ("# Table tr: odd" ).css ("background-color", "# e6e6fa ");

$ ("# Table tr: even" ).css ("background-color", "# fff0fa ");

}

</Scirpt>

 

 

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.