Native javascript implements line-by-line color change, javascript
Js allows us to learn from the basics and learn from 1.1 points.
Below is the code I wrote. Let's take a look at it !!!
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> js demo </title>
</Head>
<Body>
<Script>
Document. write ('<table border = "1" width = "100px" align = "center"> ');
Var I = 0;
While (I <100 ){
If (I % 10 = 0 ){
If (I % 20 = 0)
Bg = "# cccccc ";
Else
Bg = "# ffffff ";
Document. write ('<tr onmouseover = "show (this)" onmouseout = "onshow (this)" bgcolor = "' + bg + '"> ');
}
Document. write ('<td>' + I + '</td> ');
I ++;
If (I % 10 = 0 ){
Document. write ("<tr> ");
}
}
Document. write ("</table> ")
Var ys = null;
Function show (obj ){
Ys = obj. bgColor;
Obj. bgColor = "red ";
}
Function onshow (obj ){
Obj. bgColor = ys;
}
</Script>
</Body>
</Html>
The function is very simple, but it is very practical. For more information, see.