There is a menu display function

<script type="text/javascript"> function Menu1(id){ var menu = document.getElementById('menu_' + id).style; menu.display = 'block'; } </script> 

and there is her challenge when you hover the mouse.

 <p class="dropdown_link_active" class="active" onmouseover="javascript:Menu1('<?php echo $category['name']; ?>')" > <?php echo $category['name'] ?> 

It is necessary that the menu is displayed immediately, and not after mouse hovering. Onload does not work.

  • 2
    What prevents you initially indicate the visibility of your menu via css? class="active visible" , where in css: .visible {display: block;} - romeo
  • one
    If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

I already answered you here . I duplicate the answer here:

 <script> document.addEventListener("DOMContentLoaded", function() { Menu1('<?php echo $category['name']; ?>') }); </script> 

This code will call the Menu1 function once, immediately after the document has been loaded and parsed by the browser.