js processing form
1. Line color interval display
css style: two selectors
The code copy is as follows:
<style type="text/css">
.one{
background-color:#33ffcc;
}
.two{
backgound-color:#ffff66;
}
</style>
<script type="text/javascript">
function trcolor()
//The color of the control interval line is displayed differently
{
var tabNode = document.getElementsByTagName("table")[0];
//Get the table node
var trs = tabNode.rows;
//Get all rows in the table
for(var x=1; x<trs.length;x++)
{
if(x%2 == 1)
trs[x].className ="one";
else
trs[x].className ="two";
}
}
//Use the onload method, after the web page is loaded, run the trcolor method to realize the color of the spaced rows of the table.
window.onload = function()
{
trcolor();
}
</script>
2. Move the mouse to a certain line, change the line and brighten the color, and then move it away to restore the original color.
The code copy is as follows:
<style type="text/css">
.over{
background-color:##00ff00;
}
<style>
<script type="text/javascript">
var name;
function trMouse()
{
var tabNode = document.getELetsByTagName("table")[0];
// Through a for loop, add onmouseover and onmouseout attributes to each tr tag
for(var x=0;x<trs[x].length;x++)
{
trs[x].onmouseover = function()
{
name=this.className;
this.className="over";
}
tes[x].onmouseout = function()
{
this.className = name;
}
}
}
</script>