JS処理フォーム
1。ラインカラー間隔ディスプレイ
CSSスタイル:2つのセレクター
コードコピーは次のとおりです。
<style type = "text/css">
。1つ{
バックグラウンドカラー:#33ffcc;
}
。二{
Backgound-color:#ffff66;
}
</style>
<script type = "text/javascript">
関数trcolor()
//制御間隔線の色は異なって表示されます
{
var tabnode = document.getElementsByTagname( "table")[0];
//テーブルノードを取得します
var trs = tabnode.rows;
//テーブル内のすべての行を取得します
for(var x = 1; x <trs.length; x ++)
{
if(x%2 == 1)
trs [x] .classname = "one";
それ以外
trs [x] .classname = "two";
}
}
// onloadメソッドを使用して、Webページがロードされたら、TRCOLORメソッドを実行して、テーブルの間隔の行の色を実現します。
window.onload = function()
{
trcolor();
}
</script>
2。マウスを特定の線に移動し、線を変更して色を明るくしてから、元の色を復元するために移動します。
コードコピーは次のとおりです。
<style type = "text/css">
。以上{
バックグラウンドカラー:## 00FF00;
}
<style>
<script type = "text/javascript">
var名;
function trmouse()
{
var tabnode = document.getEletsbytagname( "table")[0];
// forループを介して、各TRタグにオンマウスオーバーとオンマウスアウト属性を追加します
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>