Categories

Tools

bitdefender

1&1 Web Hosting

Display the position of the mouse in a footer panel of the page, using jQuery


The following example shows how to obtain the coordinates of the pointer, and displays them in a bar in the footer of the page.

Code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Display the position of the mouse in a footer panel of the page, using jQuery - MdmSoft</title>
    <style type="text/css">
        body {
            margin: 0px;
            padding: 0px;
        }

        div.bottom {
            background-color: #808080;
            bottom: 0px;
            color: #fff;
            font-family: Verdana;
            font-size: 10px;
            height: 14px;
            line-height: 14px;
            padding-left: 10px;
            position: fixed;
            width: 100%;
        }
    </style>

    <script type="text/javascript"
        src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js">
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $(document).mousemove(function (e) {
                var x = e.pageX;
                var y = e.pageY;

                $('#position').html("" + x + ", " + y + " pixel");
            });
        });
    </script>
</head>
<body>
    <div class="bottom">
        <span id="position"></span>
        <br />
    </div>
</body>
</html>

Result:

Posted in jQuery by MdmSoft

If our work has been of help, you can help us with a small donation...
Our programmers will thank you!



All information contained in this web site are the property of MdmSoft. The information is provided "as is", MdmSoft will not be liable for any misuse of the code contained in these pages, nor can it be for inaccuracies, grammatical errors or other factors that may have caused damage or lost earnings. MdmSoft is not responsible for the content of comments posted by users.
The examples in this area have the educational and demonstration purposes only, and may be copied only for your reference, but cannot be used for commercial purposes, or for any other purpose, without the express written consent of MdmSoft.
MdmSoft also reserves the right to change, without notice, to your liking this web site, the pages and its sections, and may suspend temporarily or definitely the various services included on this site.
While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.