Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在鼠标移动后,使用jquery在弹出div中显示鼠标坐标_Jquery_Html_Popup_Mousemove_Mouse Coordinates - Fatal编程技术网

在鼠标移动后,使用jquery在弹出div中显示鼠标坐标

在鼠标移动后,使用jquery在弹出div中显示鼠标坐标,jquery,html,popup,mousemove,mouse-coordinates,Jquery,Html,Popup,Mousemove,Mouse Coordinates,我需要能够检查html页面内的各种元素位置。为此,我需要一个div,将鼠标坐标显示为鼠标光标附近的弹出窗口。 <html> <head> <title>Mouse positioning in jQuery</title> <script src="js/jquery-1.11.0.min.js" type="text/javascript"></script> <style> #click{ backg

我需要能够检查html页面内的各种元素位置。为此,我需要一个div,将鼠标坐标显示为鼠标光标附近的弹出窗口。


<html>
<head>
<title>Mouse positioning in jQuery</title>
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<style>
#click{
    background-color:#efefef;
    width:300px;
    height:50px;
    text-align:center;
    font:1.2em Arial;
    line-height:50px;
    display:none;
    position:absolute;
    z-index:9999;
}
</style>
<script>
$(document).ready(function(){
    //$(document).click(function(e){ // for click action
    $(document).mousemove(function(e){
        // e.pageX - gives you X position
        // e.pageY - gives you Y position
        //$('#click').html('e.pageX = ' + e.pageX + ', e.pageY = ' + e.pageY);
        $("#click").css({left:(e.pageX+20) + "px", top:(e.pageY+20) + "px"});
        $('#click').html('e.pageX = ' + e.pageX + ', e.pageY = ' + e.pageY);
        $('#click').show();
        //$('#click').slideToggle(); // for toggle show/hide popup
    });
});
</script>
</head>
<body>
On mouse move...

<div id="click">The cursor position will show in this div.</div>

</body>
</html>
jQuery中的鼠标定位 #点击{ 背景色:#EFEF; 宽度:300px; 高度:50px; 文本对齐:居中; 字体:1.2em Arial; 线高:50px; 显示:无; 位置:绝对位置; z指数:9999; } $(文档).ready(函数(){ //$(文档)。单击(函数(e){//可执行单击操作 $(文档).mousemove(函数(e){ //e.pageX-给你X位置 //e.pageY-给你Y位置 //$('#click').html('e.pageX='+e.pageX+',e.pageY='+e.pageY); css({左:(e.pageX+20)+“px”,顶:(e.pageY+20)+“px”}); $('#click').html('e.pageX='+e.pageX+',e.pageY='+e.pageY); $('#单击“).show(); //$(“#单击”).slideToggle();//用于切换显示/隐藏弹出窗口 }); }); 鼠标移动时。。。 光标位置将显示在此div中。