了解しました。これをできるだけ明確にしようと思います。親切にしてください、私はJavaScriptにとても慣れていません。
私はnavと呼ばれるdivコンテナを持っています。これは、5つのナビゲーションボタンを保持し、それらはすべて並べてフロートされています。そのコンテナの下に、underbarと呼ばれるdivコンテナがあります。これは、各nav要素の下にある単色のバーです。誰かがナビゲーションdivにカーソルを合わせると、その要素のアンダーバーの色が変わります。今、私はあなたが下に見るものを持っています、そしてそれは正しく働いています。
<div id="container">
<div id="nav">
<div id="one" onmouseover="document.getElementById('ubone').style.background='gray'" onmouseout="document.getElementById('ubone').style.background='white';"><a href="one.html">One</a> </div><!-- end of first nav -->
<div id="two" onmouseover="document.getElementById('ubtwo').style.background='gray'" onmouseout="document.getElementById('ubtwo').style.background='white';"><a href="two.html">Two</div><!-- end of second nav -->
<div id="three" onmouseover="document.getElementById('ubthree').style.background='gray'" onmouseout="document.getElementById('ubthree').style.background='white';"><a href="three.html">Three</div><!-- end of third nav -->
<div id="four" onmouseover="document.getElementById('ubfour').style.background='gray'" onmouseout="document.getElementById('ubfour').style.background='white';"><a href="four.html">Four</div><!-- end of fourth nav -->
<div id="five" onmouseover="document.getElementById('ubfive').style.background='gray'" onmouseout="document.getElementById('ubfive').style.background='white';"><a href="five.html">Five</div><!-- end of fifth nav -->
</div><!-- end of nav div -->
<div id="underbar">
<div id="ubone"></div><!-- end of first nav -->
<div id="ubtwo"></div><!-- end of second nav -->
<div id="ubthree"></div><!-- end of third nav -->
<div id="ubfour"></div><!-- end of fourth nav -->
<div id="ubfive"></div><!-- end of fifth nav -->
</div><!-- end of underbar div -->
</div><!-- end of container div-->
はい、これは問題なく動作します。しかし、私はこれらを1つずつ編集しなければならないという考えは絶対に嫌いです。複数のdivIDに対して実行できる一方で、javascript関数/ jquery(できれば)を使用してこれを単純化する最も簡単な方法は何ですか?考え/意見?ありがとう!