Solved

In Javascript, how to get the current id of the div where mouse pointer is?

Posted on 2013-05-22
6
288 Views
Last Modified: 2013-06-17
How to get the id of the div on which the mouse is currently pointing?
0
Comment
Question by:sam_net
6 Comments
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 100 total points
ID: 39189904
Like this

<div id="the-id" onmouseover="getID(this);">some text</div>

<script>
   
    function getID(obj)
    {
        alert(obj.id);
    }
</script>

Test page : http://jsfiddle.net/eyhsm/
0
 
LVL 29

Assisted Solution

by:Kumaraswamy R
Kumaraswamy R earned 100 total points
ID: 39189992
<script>
   
    function getID(obj)
    {
var lastID = null;

var hMouseover = function (e) {
    var target = e.target || e.srcElement;
    lastID = target.id;
};

if (document.addEventListener) {
    document.addEventListener('mouseover', hMouseover, false);
}
else {
    document.attachEvent('onmouseover', hMouseover);
}
</script>
0
 
LVL 4

Accepted Solution

by:
mohammad827 earned 100 total points
ID: 39190006
<script language="JavaScript">
document.onmousemove = getMouseXY;
function getMouseXY(e) {

  alert(e.srcElement.id);
  return false;
}

</script>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Assisted Solution

by:sam_net
sam_net earned 0 total points
ID: 39240840
Thanks.
0
 

Author Comment

by:sam_net
ID: 39240850
Working fine as expected
0
 

Author Closing Comment

by:sam_net
ID: 39252555
Working fine.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 34
Poster Video HTML 5 Scale to fit video 3 37
Angular.js example vocabulary extensions 5 32
is this a cms? 8 34
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now