How to make a multi-line method in an HTML document _javascript tips

Source: Internet
Author: User
Now that you know that it's a different color, you can change the color of the interlacing. There are many ways.
The most direct add bgcolor= "red" to the <tr> on each line.
Use CSS to define a line of two-color classes. Use this class alternately on each line. Such as:
TR class= "TrClass1"
TR class= "TrClass2"
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" > <HTML> <HEAD> <TITLE> New Document </TITLE> <meta name= "generator" content= "EditPlus" > <meta name= "Author" content= "" > <meta N Ame= "Keywords" content= "" > <meta name= "Description" content= "" > <style type= "text/css" > table{ width:100%; }. t1{background: #ff6600; Color:black; }. t2{background: #336699; Color:white; } </style> </HEAD> <BODY> <table cellpadding= "0" cellspacing= "0" > <tr class= "T1" & Gt <TD>1</TD><TD>1</TD><TD>1</TD><TD>1</TD><TD>1</TD> </TR> <tr class= "T2" > &LT;TD&GT;2&LT;/TD&GT;&LT;TD&GT;1&LT;/TD&GT;&LT;TD&GT;1&LT;/TD&GT;&LT;TD&GT;1&L t;/td><td>1</td> </TR> <tr class= "T1" > <TD>1</TD><TD>1</TD><TD>1</TD><TD>1</TD><TD>1</TD> </TR> <tr Class = "T2" > <td>2</td><td>1</td><td>1</td><td>1</td><td>1 </TD> </TR> <tr class= "T1" > <td>1</td><td>1</td><td>1</td& gt;<td>1</td><td>1</td> </TR> <tr class= "T2" > <td>2</td><td& Gt;1</td><td>1</td><td>1</td><td>1</td> </TR> </TABLE> < /body> </HTML>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Recommended 1
<textarea id="runcode52825"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Untitled document </title> <style type=" Text/css "> <!--TR {background-color:exp Ression ((this.sectionrowindex%2==0)? " Red ":" Blue ")}--> </style> </pead> <body> <table> <tr><td> 1th line </td><t D> Line 1th </td></tr> <tr><td> 2nd line </td><td> 2nd line </td></tr> <tr> <td> 3rd line </td><td> 3rd line </td></tr> <tr><td> 4th Line </td><td> 4th Line < /td></tr> </table> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

<textarea id="runcode4700"><script> function C (n) {if ((n%2) ==1) {document.write (' <tr valign=middle bgcolor= ' #FFFFFF ' height=28 al Ign=left> '); else {document.write (' <tr valign=middle bgcolor= ' #eeeeee "height=28 align=left> ');} } </script> <table width= "height=" border= "0" cellpadding= "0" cellspacing= "0" > <script>c (1); </SCRIPT><TD height= >blueidea.com</td> <td> 1th line </td></tr> <script>c ( 2); </script><td height= >blue</td> <td> 2nd line </td></tr> <script>c (3); </SCRIPT><TD height= >idea</td> <td> 3rd line </td></tr> <script>c (4); </ SCRIPT><TD height= >29ok.com</td> <td> 4th line </td></tr> </table></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Very recommended 2
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < HTML xmlns= "http://www.w3.org/1999/xhtml" > <pead> <meta http-equiv= "Content-type" content=; charset=gb2312 "/> <title> form alternate color </title> <style type=" text/css "media=" screen "> <!--/* PR-CSS */Table {border-collapse:collapse;border:solid #999; border-width:1px 0 0 1px;} Table td {Border:solid #999; border-width:0 1px 1px 0;} Tr.t1 td {Background-color: #fff;} /* The background color of the first line/* tr.t2 td {Background-color: #eee;} /* The background color of the second line/* TR.T3 td {Background-color: #ccc;} * * Mouse over the background color/--> </style> </pead> <body> <table id= "tab" > <tr><td>12</t D><td>12</td><td>12</td><td>12</td></tr> <tr><td>12 </td><td>12</td><td>12</td><td>12</td></tr> &LT;TR&GT;&LT;TD >12</td><td>12</td><td>12</td><td>12</td></tr> <tr><td>12</td><td>12 </td><td>12</td><td>12</td></tr> &LT;TR&GT;&LT;TD&GT;12&LT;/TD&GT;&LT;TD >12</td><td>12</td><td>12</td></tr> </table> <script type= "text/ JavaScript "> <!--var ptr=document.getelementbyid (" tab "). getElementsByTagName (" tr "); function $ () {for (i=1;i<ptr.length+1;i++) {ptr[i-1].classname = (i%2>0)? T1 ":" T2 "; }} window.onload=$; for (Var i=0;i<ptr.length;i++) {ptr[i].onmouseover=function () {this.tmpclass=this.classname; This.classname = "T3"; }; Ptr[i].onmouseout=function () {this.classname=this.tmpclass; }; }//--> </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

<ptml> <pead> <title>untitled document</title> <meta http-equiv= "Content-type" content= " text/html; charset=gb2312 "> <style> T1 {background-color: #336699; text-align:center}. t2 {background-color: #ffcc00; Text-align:center} </style> </pead> <body bgcolor= "#FFFFFF" text= "#000000" > <table id= "table1" Width= "100%" border= "0" cellpadding= "0" cellspacing= "0" > <tr><td>jsjsdjksdfdfgdfd</td></tr > <tr><td>vrtbtynyudegbg</td></tr> <tr><td>btrgjyjyukmymy</td></ Tr> <tr><td>fvdfthdhyjd</td></tr> <tr><td>htyjertyuktuijcdukdetyjety</ Td></tr> <tr><td>fdghrguiowheruighiaue</td></tr> <tr><td> Aosiiopweorhwdebfcjlhasd</td></tr> <tr><td>SDHFKAJBNELFJAOSDFA</td></tr> <tr><td> Mountain Cost </td></tr> <tr><td> is the scholar-bureaucrat consort riseOrchid Lap </td></tr> <tr><td> open foothold hard to play sense </td></tr> <tr><td> place; hurry up. </td></tr> <tr><td> of course people; the subject of the Iron Tribulus Terrestris immediately people </td></tr> <tr><td> tofu big rear probably part </td></tr> <tr><td> Just like a sudden sports like </td></tr> <tr><td> normalization as still as </ Td></tr> <tr><td> to open </td></tr> </table> <script language= "Javascript" > for (i=0;i<table1.rows.length;i++) {(i%2==0)? ( Table1.rows (i). ClassName = "T1"):(table1.rows (i) className = "T2"); } </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.