connectseekers.com

Sunday, 27 March 2016

How to Get Mouse Pointer Cordinate Inside a Div Using jQuery In Asp.Net

3/27/2016 - By Pranav Singh 0

This article will show you how you can get the coordinate of the div control on moue move using jquery in asp.net.



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


Now check the below jquery code. This code we will add into the body of the page.

 
$("#divForCordinate").mousemove(function (event) {
                var xcordinate = event.clientX;
                var ycordinate = event.clientY;
                $("#divx").html("X Cordinate : " + xcordinate);
                $("#divy").html("Y Cordinate : " + ycordinate);
            });


Now check he complete code of the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to Get Mouse Pointer Cordinate Inside a Div Using jQuery In Asp.Net</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

</head>
<body>
    <form id="form1" runat="server">
        <div id="divForCordinate" style="width: 300px; height: 300px; background: #0094ff; border: 3px solid #e7e7e7;">
        </div>
        <div id="divx"></div>
        <div id="divy"></div>
        <script>
                $("#divForCordinate").mousemove(function (event) {
                    var xcordinate = event.clientX;
                    var ycordinate = event.clientY;
                    $("#divx").html("X Cordinate : " + xcordinate);
                    $("#divy").html("Y Cordinate : " + ycordinate);
                });
        </script>
    </form>
</body>
</html>

Here I have takem three div one for object div, second for x cordinate and third for y cordinate. Now we have done run the application to check the output.



About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top