Detecting a mouse cursor type change on a web page

Is there any event that fires when the mouse cursor changes when I hover over different elements of the page?

Ideally, such an event:

window.onmousecursorchange = function(e) {
    // e would contain information about the cursor
    // eg. e.type could contain 'text','pointer', etc..
}

Note. Solution should not include jQuery or other libraries

Update

The question "possible duplicate" is marked by jQuery infact with all answers (none of which solves the problem) based on jQuery. I am looking for a clean JavaScript solution. If moderators think this is not enough to leave this question open, feel free to close it.

+5
source share
3 answers

Yes with an event onmouseenter

$('*').mouseenter(function(){
    var currentCursor = $(this).css('cursor') ;
    console.log( currentCursor );
});
+2
source
$(function(){

    $('*').hover(function(){
        $(this).data('hover',1); //store in that element that the mouse is over it
    },

    function(){
        $(this).data('hover',0); //store in that element that the mouse is no longer over it
    });

    window.isHovering = function (selector) {
        return $(selector).data('hover')?true:false; //check element for hover property
    }
});
+1
source

:

document.addEventListener('mouseover',function(e){
    var cursor = e.target.style.cursor;
    console.log(cursor);
},false);

bubbling .

+1

All Articles