首页 > 代码库 > JavaScript Set Cursor Style

JavaScript Set Cursor Style

<!DOCTYPE html><html><head><meta charset="ISO-8859-1"><title>Insert title here</title><script language="JavaScript">    function setCursorByID(id, cursorStyle) {        var elem;        if (document.getElementById && (elem = document.getElementById(id))) {            if (elem.style)                elem.style.cursor = cursorStyle;        }    }</script></head><body>    <span style="cursor: auto;">auto</span>    <span style="cursor: move;">move</span>    <span style="cursor: no-drop;">no-drop</span>    <span style="cursor: col-resize;">col-resize</span>    <span style="cursor: all-scroll;">all-scroll</span>    <span style="cursor: pointer;">pointer</span>    <span style="cursor: not-allowed;">not-allowed</span>    <span style="cursor: row-resize;">row-resize</span>    <span style="cursor: crosshair;">crosshair</span>    <span style="cursor: progress;">progress</span>    <span style="cursor: e-resize;">e-resize</span>    <span style="cursor: ne-resize;">ne-resize</span>    <span style="cursor: default;">default</span>    <span style="cursor: text;">text</span>    <span style="cursor: n-resize;">n-resize</span>    <span style="cursor: nw-resize;">nw-resize</span>    <span style="cursor: help;">help</span>    <span style="cursor: vertical-text;">vertical-text</span>    <span style="cursor: s-resize;">s-resize</span>    <span style="cursor: se-resize;">se-resize</span>    <span style="cursor: inherit;">inherit</span>    <span style="cursor: wait;">wait</span>    <span style="cursor: w-resize;">w-resize</span>    <span style="cursor: sw-resize;">sw-resize</span>    <div>        <a id="e1h" href="#" style="cursor: help;" onclick="setCursorByID(‘e1‘,‘help‘);return false;">help</a>         <a id="e1w" href="#" style="cursor: wait;" onclick="setCursorByID(‘e1‘,‘wait‘);return false;">wait</a>        <a id="e1m" href="#" style="cursor: move;" onclick="setCursorByID(‘e1‘,‘move‘);return false;">move</a>         <a id="e1c" href="#" style="cursor: crosshair;" onclick="setCursorByID(‘e1‘,‘crosshair‘);return false;">crosshair</a>        <a id="e1t" href="#" style="cursor: text;" onclick="setCursorByID(‘e1‘,‘text‘);return false;">text</a>         <a id="e1a" href="#" style="cursor: default;" onclick="setCursorByID(‘e1‘,‘default‘);return false;">default</a>         <a id="e1a" href="#" style="cursor: pointer;" onclick="setCursorByID(‘e1‘,‘pointer‘);return false;">pointer</a>         <a id="e1a" href="#" style="cursor: auto;" onclick="setCursorByID(‘e1‘,‘auto‘);return false;">auto</a>    </div>    <div>        <a id="e1" href="#" onclick="setCursorByID(‘e1‘,‘help‘);return false;">test</a>     </div></body></html>

原文:http://www.javascripter.net/faq/stylesc.htm

JavaScript Set Cursor Style