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>