I am trying to dynamically change the style of the cursor when the mouse is over an element. The cursor must be βmovedβ or βdefaultβ depending on the boolean returned by the method. The code looks something like this:
$("#elemId").mousemove(function(event) { if(cursorShouldBeMove()) { $(this).css({'cursor':'move'}); } else { $(this).css({'cursor':'default'}); } }
This code works like a charm in IE8, FF3, Chrome and Safari. Only Opera cannot handle this correctly.
I am using Opera 9.6.4
Does anyone have an idea how to solve this?
I prepared a sample for testing;
var cursorStatus = true; setInterval(function() { cursorStatus = !cursorStatus; }, 500); function cursorShouldBeMove() { return cursorStatus; } $(function() { $("#elemId").mousemove( function(event) { $(this).css("cursor", cursorShouldBeMove() ? "move" : "default"); } ); });
If you move the mouse from outside the #elemId border several times inside it, you will see that the cursor changes. But if you hover over #elemId and move the mouse, the cursor will not change.
The code is very simple. I think this is Opera bug.
I tested this code also with
- Firefox 3.5.1 (works)
- Internet Explorer 7 (works)
- Google Chrome 2.0 (works)
- Safari 3.2 (works)
(Windows versions)
source share