How to make a popup hover over a link in jquery?
<div id="floatbar">
<a href="" onclick="make it float 10px under this yay">
</div>
$(function() { $('a. popper'). hover(function() { $('#pop'). toggle(); }); });
jQuery hover() MethodThe hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.
the jquery
$("#floatbar").click(function(e){
e.preventDefault();
$(this).find(".popup").fadeIn("slow");
});
the css
#floatbar {
position:relative;
}
.popup {
position:absolute;
top:10px;
left:0px;
height:30px;
background:#ccc;
display:none;
}
the html
<a id="floatbar" href="#">
<div class="popup">Hi there</div>
click here
</a>
Pure css solution:
<div id="floatbar">
<a href="" onclick="make it float 10px under this yay">Link</a>
<div class="box">Popup box</div>
</div>
.box {
display:none;
position: absolute;
top: 30px;
left: 10px;
background: orange;
padding: 5px;
border: 1px solid black;
}
a:hover + .box {
display:block;
}
All you have to do is add a <div class="box">(popup text)</div>
below the link and it'll work for every link that has such a box.
http://jsfiddle.net/mcdqt/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With