jQuery实时显示鼠标指针位置和键盘ASCII码

jQuery实时显示鼠标指针位置和键盘ASCII码_第1张图片

<!DOCTYPE html>
<html>

    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type="text/javascript" src="js/jquery-2.1.4.js"></script>
        <script language="javascript" type="text/javascript"> $(function() { $(document).mousemove(function(e) { $("span").html("X:" + e.pageX + "Y:" + e.pageY + "事件" + e.type); //不行 document.write("X:" + e.pageX + "Y:" + e.pageY + "事件" + e.type); }); }); </script>
    </head>

    <body>

        <span></span>

    </body>

</html>

按A

jQuery实时显示鼠标指针位置和键盘ASCII码_第2张图片

<!DOCTYPE html>
<html>

    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type="text/javascript" src="js/jquery-2.1.4.js"></script>
        <script language="javascript" type="text/javascript"> $(function() { $(document).keydown(function(e) { $('span').html(e.which); }) }); </script>
    </head>

    <body>

        <span></span>

    </body>

</html>

你可能感兴趣的:(JavaScript,jquery,鼠标,指针)