---
title: "Hover on getElementById using javascript"  
description: "Hover on getElementById using javascript"  
author: "Anonymous User"  
published: 2013-08-19  
updated: 2013-08-19  
canonical: https://www.mindstick.com/forum/1401/hover-on-getelementbyid-using-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 2 minutes  

---

# Hover on getElementById using javascript

Hi!\

I hope someone can answer my [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time), it is probably easy for you but I am not very used to JavaScript.

So I made a menu using this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
function tabSwitch(new_tab, new_content) {    
document.getElementById('content_1').style.display = 'none';     
document.getElementById('content_2').style.display = 'none';     
document.getElementById('content_3').style.display = 'none';             
document.getElementById(new_content).style.display = 'block';        
document.getElementById('tab_1').className = '';     
document.getElementById('tab_2').className = '';     
document.getElementById('tab_3').className = '';             
document.getElementById(new_tab).className = 'active';      }
```

When clicking on the area of tab_1 the content_1 is displayed and so on. But I would like to get the [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) displayed when the [mouse](https://yourviews.mindstick.com/story/5122/the-story-behind-lord-ganesha-s-mouse-mushak) hovers over the area of the different tabs. Could you please help me, I looked up the [web](https://www.mindstick.com/articles/12783/the-ultimate-bunch-of-free-web-design-resources) but I could not find anything, maybe because I have actually no idea of JavaScript.

So, thanks for your time and help.

## Replies

### Reply by shreesh chandra shukla

Hi!

You could go for the onmouseover event, as it is supported for a and li tags as well, and additionally check out the onmouseout (very similar) to be aware of both.

With this, the li tags for the menu elements would look like:

```
<li onmouseover="tabSwitch('tab_1', 'content_1');"><a href="#" id="tab_1" class="active"><img src="img/flash.png" /></a></li><li onmouseover="tabSwitch('tab_2', 'content_2');"><a href="#" id="tab_2"><img src="img/brush.png" /></a></li>
```

Onmouseover will fire, when you hover over the element. I think you get the idea from here.


---

Original Source: https://www.mindstick.com/forum/1401/hover-on-getelementbyid-using-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
