To set or change the mouse cursor style for an element of your page from script, you can set the element's property element.style.cursor to one of the above values.
(Alternatively, without JavaScript, you can use the attribute style="cursor:value;" in that element's HTML tag.)
Example. The function setCursorByID below resets the mouse cursor style, given the input arguments id (the element ID) and cursorStyle (the desired cursor style):
function setCursorByID(id,cursorStyle) {
var elem;
if (document.getElementById &&
(elem=document.getElementById(id)) ) {
if (elem.style) elem.style.cursor=cursorStyle;
}
}
The following demo allows you to change the cursor styles for the highlighted elements (Element 1 and Element 2). In this demo, when you click on the hyperlink help, wait, crosshair, text, default, move, or pointer, the cursor is changed to the corresponding style for the entire highlighted element using the function setCursorByID from the above example.
When you click on the hyperlink auto, the cursor for the particular element is reset to its original style determined by the browser.
Element 1 Change cursor to any of these styles:
help wait move crosshair text default pointer auto
Element 2 Change cursor to any of these styles:
help wait move crosshair text default pointer auto