Shows a submenu when the mouse is hovered over the button
P粉021708275
P粉021708275 2023-08-31 11:22:01
0
1
647
<p>I'm looking for a solution where when I hover over a button a submenu pops up. Currently the menu is only shown when clicked. Does anyone know what I need to change so that when hovering over a button the menu shows up and when clicked the menu stays there. </p> <p>Solution: Change hover to mouseover. </p> <p><strong>Does anyone know how to make all sections (sect1...) not show on mouseover? </strong></p> <pre class="brush:php;toolbar:false;"><script> var divs var btn1 = document.getElementById("btn1"); var btn2 = document.getElementById("btn2"); var btn3 = document.getElementById("btn3"); btn1.mouseover = function(event){ event.preventDefault(); toggleDivs("sect1"); }; btn2.mouseover = function(event){ event.preventDefault(); toggleDivs("sect2"); }; btn3.mouseover = function(event){ event.preventDefault(); toggleDivs("sect3"); }; function toggleDivs(s){ //reset document.getElementById("sect1").classList.remove("shown"); document.getElementById("sect2").classList.remove("shown"); document.getElementById("sect3").classList.remove("shown"); //show document.getElementById(s).classList.add("shown"); } //force button1 state initialise, if required //btn1.focus(); //btn1.click(); </script> <style> .elementor-editor-active .hidden{ display:block; } .hidden{ display:none; } .show{ display: block !important; } </style></pre></p>
P粉021708275
P粉021708275

reply all(1)
P粉883223328

There is no "hover" event. You have to use mouseover, mouseenter and mouseout to handle it.

https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template