この要素の背景色を変更することができます:
<div onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor='red'" style="background-color:green; width:100px; height:40px;">
</div>
しかし、私は最初の子の色を変更したいと思います。これは次のように機能すると想定しました。
<div onmouseover="this.firstChild.style.backgroundColor='blue'" onmouseout="this.firstChild.style.backgroundColor='red'" style="background-color:green; width:100px; height:40px;">
<div style="background-color:white; height:10px; width:10px; margin:20px;">This is the first child, I think.</div>
</div>
しかし、それは機能しません。なにが問題ですか?firstChildのスタイルを変更するにはどうすればよいですか?
PS:後で、子にdisplay = blockを使用し、noneと他のいくつかのプロパティ(スタイルだけでなく)を使用したいと思います。色はテスト用でした。