105
A
回答
212
$('selector').css('cursor', 'pointer');
我知道你的原始问题可能会引起混淆,但“finger”游标实际上被称为“指针”。
正常的箭头光标只是“默认”。
16
更新!新&改进!查找插件@GitHub!
在另一方面,虽然that method很简单,我创建了一个jQuery插件(found at this jsFiddle, just copy and past code between comment lines),使得改变任何元素上的光标那样简单$("element").cursor("pointer")
。
但这还不是全部!立即行动,您将获得免费的手功能position
& ishover
!没错,2个非常方便的光标功能...免费!
他们的工作所看到的演示那样简单:
$("h3").cursor("isHover"); // if hovering over an h3 element, will return true,
// else false
// also handy as
$("h2, h3").cursor("isHover"); // unless your h3 is inside an h2, this will be
// false as it checks to see if cursor is hovered over both elements, not just the last!
// And to make this deal even sweeter - use the following to get a jQuery object
// of ALL elements the cursor is currently hovered over on demand!
$.cursor("isHover");
另外:
$.cursor("position"); // will return the current cursor position as { x: i, y: i }
// at anytime you call it!
供应是有限的,所以立即行动!
4
如何将光标更改为手指(如点击链接)而不是常规指针?
这是非常简单的实现使用CSS属性cursor
,没有jQuery
需要。
你可以阅读更多关于:CSS cursor property
和cursor - CSS | MDN
.default {
cursor: default;
}
.pointer {
cursor: pointer;
}
<a class="default" href="#">default</a>
<a class="pointer" href="#">pointer</a>
0
这是非常简单的
HTML
<div>
<input type="text" placeholder="sometext" />
<input type="button" value="button" class="button"/>
<br/><br/>
<button class="button"> Another button</button>
</div>
jQuery的
$(document).ready(function(){
$('.button').css('cursor', 'pointer');
// for old IE browsers
$('.button').css('cursor', 'hand');
});
相关问题
- 1. 更改指针指针指针引用
- 2. 如何将鼠标指针更改为手指指针?
- 3. 使用指针:指针指针指针
- 4. 如何使用JQuery将鼠标悬停在动态列表上时将指针更改为指针
- 5. 如何使用memmove与指针指针?
- 6. 如何使用指针和指针aritmetic
- 7. 在指针使用函数后,如何更改指针指向的对象
- 8. 将如何使用指针
- 9. 通过使用指针指针来更改引用
- 10. 为什么cudaMalloc()使用指针指针?
- 11. C:memcpy更改指针?
- 12. jqgrid更改指针
- 13. 更改指针file_put_contents()
- 14. 使用指针的指针
- 15. 将textfield()鼠标指针更改为
- 16. 如何使指针指针NULL
- 17. 为指针的指针
- 18. 如何使用双指针作为指针数组?
- 19. 通过指针指向结构指针来更改变量
- 20. 指针指针
- 21. 指针指针?
- 22. 指针指针
- 23. 指针指针
- 24. 如何使用指向Java指针的指针填充结构?
- 25. 如何使用C指针指向结构的指针?
- 26. 如何使用指针指向c#中的指针?
- 27. 如何在cuda中使用指向指针的指针
- 28. 如何将类型size_t的指针转换为枚举指针?
- 29. 如何将一组指针转换为一组const指针?
- 30. 如何将ref ^指针转换为原始指针?
如果可能的话,通过CSS做到这一点(有说:悬停选择器),并完全避免的jQuery。 – 2009-12-03 23:06:41
@The Who - 当然,但是如果改变光标是依赖于JS的功能的一部分(假设你有一个滑块),那么如果用户关闭了JS,你不会希望光标改变。 – 2011-07-08 18:46:46
我用''('selector').css('cursor','auto');'将鼠标移出指针区域时去掉样式。使用'$('...')。addClass('someclass')'和'$('...')。removeClass('someclass')' – jocull 2011-11-14 04:07:38