Using JavaScript to make color intervals between rows

Source: Internet
Author: User
JavaScript makes pages, sometimes in order to get rid of the monotonous color display between table rows and rows, seeking a simple visual effect that requires a different color display between each row. The general production, all by hand to adjust the color, so that the management table is extremely inconvenient. The solution is to use JavaScript and CSS to control.

Production method:
1. Insert CSS style between . T1 {background-color: #336699}
. t2 {background-color: #ffcc00}
Where the #336699与 #ffcc00 is the color value for each row of rows.

2. Insert the table using Dreamweaver. and give the table the ID value: <table id= "table1" >

3. Insert JavaScript code under form <table>...</table> code:
<script language= "Javascript1.2" >
for (i=0;i<table1.rows.length;i++) {
(i%2==0)? (Table1.rows (i). ClassName = "T1"):(table1.rows (i) className = "T2");
}
</script>

Make a complete, please make a look at their own effect bar!!

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.