Hide cursor

1,054 views
Skip to first unread message

Mathias Schmitz

unread,
Jun 12, 2018, 9:17:41 AM6/12/18
to jsPsych
Hi,

Is there a way to hide the cursor during during a given task?

Best,
Mathias

Josh de Leeuw

unread,
Jun 12, 2018, 9:24:00 AM6/12/18
to Mathias Schmitz, jsPsych
You can set the CSS style cursor: none on the html element. If you need to toggle the cursor on and off I suggest using a call-function trial and injecting the <style> tag into the <head> element. Something like this:

// hides cursor by adding CSS
document.querySelector('head').insertAdjacentHTML('beforeend', '<style id="cursor-toggle"> html { cursor: none; } </style>');

// shows cursor by removing CSS
document.querySelector('#cursor-toggle').remove();

Cheers,
Josh

--
You received this message because you are subscribed to the Google Groups "jsPsych" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspsych+u...@googlegroups.com.
To post to this group, send email to jsp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jspsych/16d8539a-c86c-4fb0-8c21-415033fdead7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mathias Schmitz

unread,
Jun 12, 2018, 9:56:54 AM6/12/18
to jsPsych
Thanks for the advice, I added two lines in the task itself and it seems to work :

on_start: function() {$('body').css('cursor', 'none')},
on_finish
: function() {$('body').css('cursor', 'default')}
Reply all
Reply to author
Forward
0 new messages