效果如图
<html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=GB2312">
<title>学生信息系统</title>
<script language="javascript">
var showInfo = new function () {
this.showLayer = function (e, id) {
var p = window.event ? [event.clientX, event.clientY] : [e.pageX, e.pageY]
with (document.getElementById(id + "").style) {
display = "block"
left = p[0] + 10 + "px"
top = p[1] + 10 + "px"
}
if (window.event) {
window.event.cancelBubble = true
} else {
if (e) {
e.preventDefault()
}
}
}
this.hideLayer = function (e, id) {
with (document.getElementById(id + "").style) {
display = "none"
}
if (window.event) {
window.event.cancelBubble = true
} else {
if (e) {
e.preventDefault()
}
}
}
}
</script>
<style type="text/css">
.helplay {
z-index: 3
position: absolute
border: 1px solid #FFC30E
padding: 5px
background-color: #FFFBB8
text-align: left
color: #9C7600
width: 130px
font-size: 15px
font-family: arial, sans-serif
}
</style>
</head>
<body>
<table width="760" border="0" align="center">
<tr>
<td width="20%" height="46"></td>
<td width="60%" align="center">
学生信息系统
</td>
<td width="20%"></td>
</tr>
<tr>
<td width="20%" height="272" align="center"></td>
<td align="center">
<table>
<tr>
<div style="display: none" id="C1320" class="helplay">
学号:222222<br>
年龄:18<br>
班级:2<br>
专业:软开<br>
学院:软件学院
</div>
</tr>
<tr>
<td bgcolor="#ffffaa" rowspan=2>姓名
</td>
<td colspan="2" bgcolor="#ffffaa">
<div id="C13" href="#"
onmouseover="return showInfo.showLayer(event,'C1320')"
onmouseout="return showInfo.hideLayer(event,'C1320')">
<b>张三</b>
</div>
</td>
<td bgcolor="#ffffaa" rowspan=2>
待定
</td>
</tr>
<tr>
<div style="display: none" id="C1220" class="helplay">
学号:1111<br>
年龄:28<br>
班级:1<br>
专业:软开<br>
学院:软件学院
</div>
</tr>
<tr>
<td bgcolor="#ffffaa" rowspan=2>姓名
</td>
<td colspan="2" bgcolor="#ffffaa">
<div id="C12" href="#"
onmouseover="return showInfo.showLayer(event,'C1220')"
onmouseout="return showInfo.hideLayer(event,'C1220')">
<b>李四</b>
</div>
</td>
<td bgcolor="#ffffaa" rowspan=2>
待定
</td>
</tr>
</table>
</td>
<td width="20%" align="center"></td>
</tr>
</table>
</body>
</html>
首先随便找一个地方新建一个div 并且隐藏。例如<div id='showTip' style="background-color: white width:200pxheight:200pxposition: absolutedisplay: none">
</div>
然后在链接那边写个onmouseover 属性加个触发方法 如showDiv()具体方法如下
function showDiv(e){
$("#showTip").html("这里可以写一些html的内容,如图片文字")
$("#showTip").css("top",e.clientY)//这里可以根据情况适当调整
$("#showTip").css("left",e.clientX)
$("#showTip").show()
}
还要在链接那边加上 onmouseout属性触发方法如下:
function hideDiv(){
$("#showTip").hide()
}
以上需要引入jquery支持