javascript 怎么鼠标停留在表格的某个单元格上,获得该单元格的值_百度...
发布网友
发布时间:2022-04-26 15:15
我来回答
共1个回答
热心网友
时间:2022-04-24 16:04
跟随鼠标移动
<script type="text/javascript" src="inc/jquery.v1.3.js"></script>
我链接了自己的jQuery文件,你换成自己的就可以用了:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
background-color:#FF0;
left:159px;
top:100px;
width:100px;
height:100px;
z-index:99;
display:none;
text-align:center;
}
-->
</style>
<script type="text/javascript" src="inc/jquery.v1.3.js"></script>
<script type="text/javascript">
$(function(){
$("td").mouseover(function(){
$("#apDiv1").show().html($(this).html());
})
$("td").mousemove(function(event){
var x= event.pageX + 10 + "px";
var y= event.pageY + 10 + "px";
$("#apDiv1").css({"left":x,"top":y});
})
$("td").mouseout(function(){$("#apDiv1").hide(); })
})
</script>
</head>
<body>
<div id="apDiv1">aaa</div>
<div>
<table width="200" border="1" id="table1">
<tr>
<td>1-1</td>
<td>1-2</td>
<td>1-3</td>
</tr>
<tr>
<td>2-1</td>
<td>2-2</td>
<td>2-3</td>
</tr>
<tr>
<td>3-1</td>
<td>3-2</td>
<td>3-3</td>
</tr>
</table>
</div>
</body>
</html>