前段时间要实现一个效果,当鼠标点击某列表中的一行时,弹出个DIV显示该行中的所有内容,所以要实现的是

当点击出现DIV时,这个弹出的DIV是捕捉到鼠标坐标后显示的,这样就能体现出点击的是哪行,显示的是哪行

的内容了,简单代码如下:

 

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title>无标题页</title>

    <script language="javascript" type="text/javascript">

function followcursor(){
var DIV = document.getElementById('div01');
DIV.style.display = "block";
DIV.style.left=document.body.scrollLeft+event.clientX+10
DIV.style.top=document.body.scrollTop+event.clientY+10
}
    </script>

</head>
<body>
    <form >
        <div style="width: 300px; height: 300px; border: solid 1px #ccc; display: none;position:absolute;"
            >
            跟随鼠标显示的DIV<a href="javascript:void(0)" onclick="document.getElementById('div01').style.display='none';">关闭</a>
        </div>
        <div>
            <a href="javascript:void(0)" onclick="followcursor();">点一</a></div>
        <div style="position: absolute; top: 300px; left: 400px;">
            <a href="javascript:void(0)" onclick="followcursor();">点二</a></div>
    </form>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案