7

マウス カーソルがさまざまなページ要素の上に移動したときにトリガーされるイベントはありますか?

次のようなイベントが理想的です。

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

注: ソリューションには、jQuery やその他のライブラリを含めないでください。

更新

「重複の可能性」の質問は、すべての回答(問題を解決するものはありません)がjQueryに基づいているという事実にjQueryでタグ付けされています。純粋な JavaScript ソリューションを探しています。モデレーターが、これがこの質問を開いたままにしておく十分な理由ではないと考える場合は、遠慮なく閉じてください。

4

3 に答える 3

3

これを試すことができます:

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

イベントバブリングを使用して、パフォーマンスを向上させ、コードを節約します。

于 2013-01-27T12:45:22.710 に答える
2

はいイベントありonmouseenter

$('*').mouseenter(function(){
    var currentCursor = $(this).css('cursor') ;
    console.log( currentCursor );
});
于 2013-01-26T17:06:41.760 に答える
1
$(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
    }
});
于 2013-01-26T17:10:44.190 に答える