Tengo un menu tipo acordeon vertical con el siguiente código
Código:
Me lo han dado hecho y tengo que modificarlo para que cuando se despliege y se elija un enlace del submenu, el menu se quede desplegado y no se cierre como ocurre ahorafunction muestra(menu) { var divName = "submenu_" + menu.toLowerCase(); var btnName = "menu_" + menu; if (document.getElementById(divName).style.display != "block") { document.getElementById(divName).style.display = "block"; document.getElementById(btnName).setAttribute("style", "background-image:url(images/" + menu.toLowerCase() + "_on.gif);"); } else { document.getElementById(divName).style.display = "none"; document.getElementById(btnName).setAttribute("style", "background-image:url(images/" + menu.toLowerCase() + ".gif);"); } }
Este es el codigo del menu en html
Código HTML:
<div id="menu"> <h2>Menu</h2> <ul> <li id="menu_home_fondo"><a href="index.php" id="menu_home" title="Home"><span>Home</span></a></li> <li id="menu_about_us_fondo"><a href="02_about_us.php" id="menu_about_us" title="About us"><span>About us</span></a></li> <li id="menu_services_fondo"><a href="03_services.php" id="menu_services" title="Services"><span>Services</span></a></li> <li id="menu_property_finding_fondo"><a href="04_property_find.php" id="menu_property_finding" title="Property Finding"><span>Property Finding</span></a></li> <li id="menu_sell_fondo"><a href="05_sell_your_prop.php" id="menu_sell" title="Sell your property"><span>Sell your property</span></a></li> <li id="menu_property_visits_fondo"><a href="06_property_visits.php" id="menu_property_visits" title="Property Visits"><span>Property Visits</span></a></li> <li> <div id="menu_area_guides_fondo"><a href="javascript:;" title="Area Guides" id="menu_area_guides" onclick="muestra('area_guides')"><span>Area Guides</span></a></div> <div id="submenu_area_guides"> <ul> <li><strong>• </strong><a href="07_01_aragon.php" title="Aragón"><span>Aragón</span></a></li> <li><strong>• </strong><a href="07_02_asturias.php" title="Asturias"><span>Asturias</span></a></li> <li><strong>• </strong><a href="07_03_cantabria.php" title="Cantabria"><span>Cantabria</span></a></li> <li><strong>• </strong><a href="07_04_castilla_la.php" title="Castilla la Mancha"><span>Castilla la Mancha</span></a></li> <li><strong>• </strong><a href="07_05_castilla_leon.php" title="Castilla León"><span>Castilla León</span></a></li> <li><strong>• </strong><a href="07_06_cataluna.php" title="Catalonia"><span>Catalonia</span></a></li> <li><strong>• </strong><a href="07_07_extremadura.php" title="Extremadura"><span>Extremadura</span></a></li> <li><strong>• </strong><a href="07_08_galicia.php" title="Galicia"><span>Galicia</span></a></li> <li><strong>• </strong><a href="07_09_la_rioja.php" title="La Rioja"><span>La Rioja</span></a></li> <li><strong>• </strong><a href="07_10_madrid.php" title="Madrid"><span>Madrid</span></a></li> </ul> </div> </li> <li> <div id="menu_key_info_fondo"><a href="javascript:;" onclick="muestra('key_info');" id="menu_key_info" title="Key Buyer Information"><span>Key Buyer Information</span></a></div> <div id="submenu_key_info"> <ul> <li><strong>• </strong><a href="08_01_buying.php" title="Buying process"><span>Buying process</span></a></li> <li><strong>• </strong><a href="08_02_cost.php" title="Cost of buying"><span>Cost of buying</span></a></li> <li><strong>• </strong><a href="08_03_property.php" title="Property Values"><span>Property Values</span></a></li> <li><strong>• </strong><a href="08_04_the_weather.php" title="The weather"><span>The weather</span></a></li> <li><strong>• </strong><a href="08_05_airports.php" title="Airports"><span>Airports</span></a></li> <li><strong>• </strong><a href="08_06_rail.php" title="Rail network"><span>Rail network</span></a></li> <li><strong>• </strong><a href="08_07_ferries.php" title="Ferries"><span>Ferries</span></a></li> <li><strong>• </strong><a href="08_08_education.php" title="Education"><span>Education</span></a></li> <li><strong>• </strong><a href="08_09_medical.php" title="Medical care"><span>Medical care</span></a></li> <li><strong>• </strong><a href="08_10_ski.php" title="Ski"><span>Ski</span></a></li> <li><strong>• </strong><a href="08_11_golf.php" title="Golf"><span>Golf</span></a></li> <li><strong>• </strong><a href="08_12_camino.php" title="Camino de Santiago"><span>Camino de Santiago</span></a></li> </ul> </div> </li> <li> <div id="menu_living_fondo"><a href="javascript:;" onclick="muestra('living');" id="menu_living" title="Make a living"><span>Make a living</span></a></div> <div id="submenu_living"> <ul> <li><strong>• </strong><a href="09_01_language.php" title="Language Academy"><span>Language Academy</span></a></li> <li><strong>• </strong><a href="09_02_rural.php" title="Rural Hotel Set-up"><span>Rural Hotel Set-up</span></a></li> <li><strong>• </strong><a href="09_03_wine.php" title="Wine business"><span>Wine business</span></a></li> </ul> </div> </li> <li id="menu_fees_fondo"><a href="10_fees.php" id="menu_fees" title="Fees"><span>Fees</span></a></li> <li id="menu_links_fondo"><a href="11_links.php" id="menu_links" title="Links"><span>Links</span></a></li> <li id="menu_contact_us_fondo"><a href="12_contact_us.php" id="menu_contact_us" title="Contact us"><span>Contact us</span></a></li> </ul> <div class="clear"></div> </div>