<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
body
{
margin: 0px;
}
#div1
{
margin: 0 auto;
margin-top: 20px;
position: inherit;
border: 1px solid #CCC;
width: 500px;
height: 500px;
}
li
{
float: left;
list-style-type: none;
margin-left: 15px;
margin-top: 30px;
margin-right: 15px;
}
li img
{
border: 1px solid #CCC;
}
#ddd
{
width: 209px;
height: 150px;
position: absolute;
background-image: url(images3/bj_txt.jpg);
background-repeat: no-repeat;
text-align: center;
color:#6C6C6C;
border-bottom:1px solid #D0D0D0;
font-weight:bold;
}
</style>
<script src="Jquery1.7.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var xinxi = new Array("多米音乐", "腾讯微博", "酷我音乐", "梦幻泡泡龙", "K歌大人", "我查看", "熊猫看书", "QQ空间", "58同城", "捕鱼之海底", "掌上药柜");
//加载li
var strli = "";
function s() {
for (var i = 1; i < 12; i++) {
strli = strli + "<li><img src='images3/" + i + ".png' alt=" + i + " width=48 height=48/></li>"
}
return strli;
}
$("ul").append(s());
//给li img添加事件
$("li img").hover(function () {
var lm = $(this).offset();
//alert("left:" + lm.left + "top:" + lm.top);
var str = "";
str = "<div id='ddd' style='top:" + lm.top + "px; left:" + (lm.left + 52) + "px'><br>";
//$(this).attr("title")
str = str + xinxi[$(this).attr("alt")-1];
str = str + "</div>";
$("body").append(str);
},
function () {
$("#ddd").remove();
})
})
</script>
</head>
<body>
<div id="div1">
<ul>
</ul>
</div>
</body>
</html>
效果如下: