Javascript) I used addEventListener to use 'mouseover' but it doesn't work. I can't figure out the problem

Brian

I want make my 'id=submenu' "visibility:hidden" to "visibility:visible" When I mouseover 'class=recipe'. I tried inline,property Listener but It doesn't works. I know I'm very ignorant but I can't find What should I do. Can you help me to solve this problem? Here's my code. Sorry.

var t = document.getElementByClass('recipe');
t.addEventListener('mouseover', Function(sHover) {
  var a = document.getElementById('submenu');
  a.style.visibility = 'visible';
});
#submenu {
  visibility: hidden;
}
<div class="mainmenu">
  <a class="first" href="Home.html">Home</a>
  <a class="recipe" href="Recipe.html">Recipe</a>
  <a href="QNA.html">QNA</a>
  <div id="submenu">
    coffee
  </div>
</div>

Eugen Sunic

Try this, you have to pull out the element from the array.

Also, it's not getElement.. but getElementsByClass

var t = document.getElementsByClass('recipe')[0];
t.addEventListener('mouseover', function(sHover) {
  var a = document.getElementById('submenu');
  a.style.visibility = 'visible';
});

You should consider using querySelector(".recipe") instead

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

clearInterval() doesn't work and I can't figure out why

I can't figure out why 100% width doesn't work with a background image

I can't figure out the problem with this merge sort algorithm

I can't figure out how to use an android PreferenceActivity

I can't figure out how to use Promise correctly in this context

My Javascript output is reversed and I can't figure out why

ArgumentOutOfRangeException and I can't figure out why

I can't figure out the closure for this

I can't figure out this query

Some Thing that I Can't Figure Out

A result that I can't figure out

ValueError + repetition I can't figure out

I can't figure these errors out

Syntax error that I can't figure out

I can't figure out this sequence - 11110000111000110010

Error with an if statement that I can't figure out

I can't get addEventListener to work properly

(FLASK) I can't figure out why my html file doesn't update/render

How to upgrade Ruby version when I can't figure out which program was used to install Ruby?

My JavaScript doesn't work. How can I solve this problem?

I can't figure out why the list isn't loading

I have an argument issue and I can't figure out why?

I can't figure out why the javascript generated <tr> elements aren't being styled by my stylesheet

Oracle SQLDevelopper SQL TRIGGER Creation Problem That I Can't Figure Out

I can't figure out why I'm reading wrong input in reading array elements in codechef problem for reverse array problem

I can't figure out why dropna() does not work in my code

I can't figure out how to get display property to work when it comes to multiple div elements

I can't figure out how to work with the object returned by Firebase get query

I'm trying to write a function that overwrites a specific line of a file, and I cannot figure out why it doesn't work

TOP Ranking

HotTag

Archive