ho fatto un menu a tendina in javascript tramite i div comparsa, il codice e' il seguente:
si può notare che passando il mouse sopra il link "gaming" si aprono le sue sottocategorie come fps, rpg ed altro mentre passando il mouse su "tecnologia" si aprono le sue sottocategorie come software,apple ecc...codice:<html> <head> <script type="text/javascript" language="javascript"> function visualizza(id){ if (document.getElementById){ if(document.getElementById(id).style.display == 'none') // se l'elemento è invisibile { document.getElementById(id).style.display = 'block'; // rendi visibile l'elemento; non sulla stessa linea if (id == 'sottomenu_game') {document.getElementById('sottomenu_tec').style.display = 'none'; } // se clicchi su game nascondi tec if (id == 'sottomenu_tec') {document.getElementById('sottomenu_game').style.display = 'none'; } // se clicchi su tec nascondi game } else{ document.getElementById(id).style.display = 'none'; } } } function nascondi(id) { document.getElementById('sottomenu_game').style.display = 'none'; // se togli il mouse dal menu scompare document.getElementById('sottomenu_tec').style.display = 'none' // se togli il mouse dal menu scompare } </script> </head> <body> <div > <a href="#" id="categoria_game" onmouseover="visualizza('sottomenu_game');" onmouseout="nascondi()"> gaming</a> <a href="#" id="categoria_tec" onmouseover="visualizza('sottomenu_tec'); " onmouseout="nascondi()"> tecnologia</a></div> <div id="sottomenu_game" style="display:none;"> action avventura sparatutto rpg sport other </div> <div ></div> <div id="sottomenu_tec" style="display:none"> apple smartphone linux other software other </div> </body> </html>
Il problema però sta nel fatto che togliendo il mouse dai due link i sottomenu scompaiono. Nessun problema, meglio così direte voi, purtroppo anche passando dal menu gaming ai suoi sottomenu (fps,rpg,sport) questi ultimi scompaiono rendendo impossibile la scelta degli stessi