I'm using this code to get cursor type (using jQuery):
$('*').mouseenter(function(){
var cursor = $(this).css('cursor');
console.log(cursor);
});
But on some elements it prints auto
(which is the default option and means that the browser determine the cursor type).
I need to be able to know what the browser actually displays in those cases (i.e. pointer
, resize
, etc.)
For example: for a link element (tagName=A) it prints 'auto', but displays 'pointer'.
How can I know which cursor type will be eventually displayed on the specific browser? In other words, how can I tell which cursor type the browser will choose?
Is this behavior documented somewhere?
Step 1: Click on the Search box located in the taskbar. Step 2: Type in "mouse." Step 3: Select Change your mouse settings from the resulting list of options to open the primary mouse settings menu. Step 4: Select Additional mouse options.
Once you're in Mouse settings, select Additional mouse options from the links on the right side of the page. In Mouse Properties, on the Pointer Options tab, at the bottom, select Show location of pointer when I press the CTRL key, and then select OK.
You can simply use the CSS cursor property with the value pointer to change the cursor into a hand pointer while hover over any element and not just hyperlink. In the following example when you place the cursor over the list item, it will change into a hand pointer instead of the default text selection cursor.
This is determined by the user agent (=browser), which uses the platform specific default cursor for the element you are currently hovering.
general purpose cursors
'auto'
The UA determines the cursor to display based on the current context, specifically: auto behaves as text over text, and default otherwise.
So you cannot possibly tell what the cursor will look like when it is set to auto in the css.
I guessed there should be an overview which html element receives which cursor type so you could just decide based on the element type, but I could not find anything online. Also, there is no guarantee, that a certain browser will actually use that cursor, since auto
gives them free reign, which cursor type to use.
The only option to have control over this is to explicitely set the cursor to a specific type. (Also, I would be interested in a detailed use case where you need this).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With