HTML DOM cursor 屬性
定義和用法
cursor 屬性規(guī)定所顯示的指針(光標(biāo))的類型。
語法:
Object.style.cursor=cursortype
可能的值
值 | 描述 |
---|---|
url |
需被使用的自定義光標(biāo)的URL 注釋:請(qǐng)?jiān)诖肆斜淼哪┒耸冀K定義一種普通的光標(biāo),以防沒有由 URL 定義的可用光標(biāo)。 |
default | 默認(rèn)光標(biāo)(通常是一個(gè)箭頭) |
auto | 默認(rèn)。瀏覽器設(shè)置的光標(biāo)。 |
crosshair | 光標(biāo)呈現(xiàn)為十字線。 |
pointer | 光標(biāo)呈現(xiàn)為指示鏈接的指針(一只手) |
move | 此光標(biāo)指示某對(duì)象可被移動(dòng)。 |
e-resize | 此光標(biāo)指示矩形框的邊緣可被向右(東)移動(dòng)。 |
ne-resize | 此光標(biāo)指示矩形框的邊緣可被向上及向右移動(dòng)(北/東)。 |
nw-resize | 此光標(biāo)指示矩形框的邊緣可被向上及向左移動(dòng)(北/西)。 |
n-resize | 此光標(biāo)指示矩形框的邊緣可被向上(北)移動(dòng)。 |
se-resize | 此光標(biāo)指示矩形框的邊緣可被向下及向右移動(dòng)(南/東)。 |
sw-resize | 此光標(biāo)指示矩形框的邊緣可被向下及向左移動(dòng)(南/西)。 |
s-resize | 此光標(biāo)指示矩形框的邊緣可被向下移動(dòng)(北/西)。 |
w-resize | 此光標(biāo)指示矩形框的邊緣可被向左移動(dòng)(西)。 |
text | 此光標(biāo)指示文本。 |
wait | 此光標(biāo)指示程序正忙(通常是一只表或沙漏)。 |
help | 此光標(biāo)指示可用的幫助(通常是一個(gè)問號(hào)或一個(gè)氣球)。 |
實(shí)例
本例改變指針:
<html>
<head>
<script type="text/javascript">
function changeCursor()
{
document.body.style.cursor="crosshair";
document.getElementById("p1").style.cursor="text";
}
</script>
</head>
<body>
<p id="p1">This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text.</p>
<input type="button" onclick="changeCursor()"
value="Change cursor" />
</body>
</html>