Bigtech Ideas
Bigtech Ideas

Reputation: 105

Display div on mouse hover

I have a link id="show" in header and a div id="display" in footer. I want to display div id="display" when mouse hover on id="show" that is in header area and div is in footer area.

HTML CODE:

<header>
<a href="#" id="show"><span> Show Div </span></a>
</header>
<---- Other Content -->
<footer>
<div id="display"> --- Content --- </div>
</footer>

Upvotes: 0

Views: 1001

Answers (3)

Bijomon Varghese
Bijomon Varghese

Reputation: 193

Hope this is what you are looking for.

http://jsfiddle.net/rxffwyux/

HTML

<header>
    <a href="#" id="show"><span> Show Div </span></a>
</header>
<---- Other Content -->
    <footer>
        <div id="display"> --- Content --- </div>
    </footer>

CSS

#display {
    display: none;
}

Js

(function() {
        $(function() {
            //On Dom Ready
            $('body').on({
                mouseenter: function() {
                    $('#display').show();
                },
                mouseleave: function() {
                    $('#display').hide();
                }
            }, '#show');
        });
    }());

Upvotes: 1

Josh
Josh

Reputation: 725

Without JQuery:

document.getElementById('show').onmouseover = function(evt) { 
   document.getElementById('display').style.display = "inline";
}

Upvotes: 1

Bhushan Kawadkar
Bhushan Kawadkar

Reputation: 28513

Try this : You can use .hover() function as shown below. Pass comma seprated functions to it. First function to call when mouseover and second for mouseleave event.

$(function(){
  $('#show').hover(function(){
     $('#display').show();
   },function(){
     $('#display').hide();
  });
}):

Upvotes: 2

Related Questions