テキストフィールドの色をマウスが乗ったら変える


動作ブラウザ 【 IE:4.0  NN:6.0
Internet Explorer Netscape Navigator DreamPassport iCab
3.0x 4.0x 4.5 5.0x 5.5 2.0x 3.0x 4.0x 4.x 6.0 2 3 2.x
Windows × - × × × × - × -
Macintosh × - × × × × - - ×
UNIX - - - - - × × × × - - -
Dreamcast - - - - - - - - - - × × -

ポイント <input type="text" onMouseover="this.style.backgroundColor='yellow'" onMouseout="this.style.backgroundColor='white'">
説  明 マウスが乗ったらテキストフィールドの背景色を変えるには「this.style.backgroundColor」に色名またはカラーコードを設定します。thisはテキストフィールド自身を表します。つまり自分自身のスタイルを変更することになります。
サンプル <html> <head> <title>テキストフィールドの色をマウスが乗ったら変える</title> </head> <body> <form name="myFORM"> <input type="text" onMouseover="this.style.backgroundColor='yellow'" onMouseout="this.style.backgroundColor='white'"> </form> </body> </html>
補足説明 なし

■サンプルスクリプトを実行する >>実行
■各ブラウザでの動作結果を見る >>View!

写真素材 PIXTA