1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:silver;
}
#nav{
position:relative;
margin: 200px auto auto auto;
width:330px;
height:50px;
}
#nav div {
display:block;
float:left;
width:108px;
height:auto;
background-color:red;
border:1px solid green;
}
#nav div > img {
display:none;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="nav">
<div><img src="test.jpg" />Text1</div>
<div><img src="test.jpg" />Text2</div>
<div><img src="test.jpg" />Text3</div>
</div>
<script language="JavaScript">
$(document).ready(function(){
$("#nav div").hover(
function(){
$(this).find("img").each(function(){
$(this).slideDown("slow");
});
}, function() {
$(this).find("img").each(function(){
$(this).slideUp(1000);
});
}
);
});
</script>
</body>
</html> |
Partager