0

在下拉菜单中,当我将鼠标悬停在相应的子菜单上时,我希望菜单元素保持其背景。

这是脚本:

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <h:outputStylesheet name="style.css" library="css" />
    <h:outputStylesheet name="styleTableExpansion.css" library="css" />
    <ui:insert name="tohead">content</ui:insert>
    <script type="text/javascript">
        function affecter_back(){
            var a = document.getElementById("menuparam")
            a.style.backgroundColor = 'red';
        }
    </script>
</h:head>

这是HTML:

<div id="templatemo_menu">
  <ul id="menuDeroulant">
    <li><a href="/impression/faces/vues_admin/acceuil_admin.xhtml" class="current"><span class="home">Acceuil</span></a></li>
    <li><a href="/impression/faces/vues_admin/touslesCommandes.xhtml" class="commandes"><span class="commandes">Commandes</span></a></li>
    <li><a href="/impression/faces/vues_admin/utilisateurs.xhtml"><span class="users">Utilisateurs</span></a></li>
    <li><a href="/impression/faces/vues_admin/newMessage.xhtml"><span class="gallery">Message</span></a></li>
    <li><a href="/impression/faces/vues_admin/historiqueMessages.xhtml"><span class="contact">Messages</span></a></li>
    <li>
      <a id="menuparam" href="/impression/faces/vues_admin/historiqueMessages.xhtml"><span class="contact2">Paramétres</span></a>
      <ul class="sousMenu">
        <li><a onmouseover="affecter_back()" href="#">CSS</a></li>
        <li><a onmouseover="affecter_back()" href="#">Graphic design</a></li>
        <li><a onmouseover="affecter_back()" href="#">Development tools</a></li>
        <li><a onmouseover="affecter_back()" href="#">Web design</a></li>
      </ul>
    </li>
  </ul>     
</div>

但它没有做我想要的。有任何想法吗?

4

0 回答 0