2010-07-08 59 views
1

我是JQuery的新手。
我想在我的HTML網頁中添加一些代碼來更改光標,
但我不確定是否使用JQuery單獨執行此操作的最佳方式,而不是在外部CSS中執行一些自定義聲明。
(我不知道是否jQuery提供了一些內置的CSS屬性。)什麼是在JQuery中更改遊標的最佳方法

這裏是我的非常簡單的HTML網頁代碼:

<script type="text/javascript"> 
$(document).ready(function(){ 
    $("#replybox").draggable();   
     $("#closed").mouseover(function(){ 
     $("#closed").css("cursor","pointer"); 
     });   
}); 
</script> 
<div id="replybox"> 
<form> 
<table border="2"> 
<tr><td align="center" bgcolor="#FFAAAA"> 
<span id="closed">Press here to close this box</span></td></tr> 
<tr> 
<td align="center"> 
Content:<textarea name="data[Reply][quote]" id="data[Reply][quote]" cols="72" rows="18">Helloworld</textarea> 
</td> 
</tr> 
</table> 
</form> 
</div> 

請指教。

+0

忘記JQuery的。你想要CometCursor。 ::鴨:: – 2010-07-08 20:55:14

回答

1

您可以在CSS中做到這一點還有:

span.crosshair {cursor:crosshair} 
span.help {cursor:help} 
span.wait {cursor:wait} 
1

爲什麼不是$("#closed").css("cursor", "pointer");以外的mouseover?默認情況下,只有鼠標懸停在元素上時,纔會顯示光標。

但是,如果您從頭開始知道元素#closed將具有指針遊標,爲什麼不把它放在樣式表中?類似於#closed { cursor: pointer; }。這將讓它適用於禁用JavaScript的人員。

相關問題