I am new to JavaScript and struggling to find a solution.
Despite searching online for fixes, none of the solutions I've found seem to work for me. I have spent hours troubleshooting the issue but I must be missing something crucial. Can someone please help?
CSS: I have created a basic two-column div (out of 12 columns) with a CSS transition that increases its width from 2% to 15% on hover.
HTML: Inside the div, I have added some test links which are currently hidden using a CSS class.
JS: My goal is to use JavaScript to make these links visible when the mouse hovers over the div.
HTML:
<div id="linkpopout" class="col-2 popout">
<a href="www.bing.com" class="menulinks">Bing</a>
<a href="www.yahoo.com" class="menulinks">Yahoo</a>
<a href="www.google.com" class="menulinks">Google</a>
</div>
CSS:
.col-2 {width: 16.66%;}
.popout {
background:lightblue;
transition:width 0.5s, height 0.5s;
transition-timing-function:ease-out;
width:2%;
height:300px;
float:left;
}
.popout:hover {
width:15%;
height:300px;
}
.menulinks {
visibility:hidden;
}
JS:
var linkpop = document.getElementById("linkpopout");
var popoutlinks = document.getElementsByClassName("menulinks");
linkpop.addEventListener("mouseover", makeVisible);
function makeVisible() {
popoutlinks.style.visibility="visible";
}
In addition to trying
document.getElementsByClassName(menulinks").style.visibility="visible";
I also attempted to use opacity instead of visibility, but it had no effect.
Thank you.