Hover Element, Show Another (CSS/Javascript/jQuery)
By | Thursday, December 1, 2011


Hide Comments
Sup-Content 1
Content 1


Sup-Content 2
Content 2




Code:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$(".group").mouseover(function(){
var child = $(this).children(".hidden_content"); //HIDDEN CONTENT OBJECT
var height = child.height(); //HIDDEN CONTENT'S HEIGHT
child.css({"margin-top":"-"+height+"px"}).show(); //SHOWS CONTENT JUST COMPLETELY ABOVE MAIN CONTENT
}).mouseout(function(){
$(this).children(".hidden_content").hide(); //CONTENT IS HIDDEN AGAIN
});
});
</script>
<style>
.group {
position: relative; !important
}
.hidden_content {
display: none; !important
position: absolute; !important
width: inherit;
z-index: 1;
}
</style>
</head>
<div class="group">
<div class="hidden_content">Sup-Content 1</div>
Content 1
</div><br><br>
<div class="group">
<div class="hidden_content">Sup-Content 2</div>
Content 2
</div><br><br>
<div class="group">
<div class="hidden_content">Sup-Content 1</div>
Content 1
</div><br><br>
<div class="group">
<div class="hidden_content">Sup-Content 2</div>
Content 2
</div>
</body>
</html>