[英]How to override css cursor property of a hovered button?
I have a <button>
, when the user hover it, the cursor become pointer (via CSS). 我有一个<button>
,当用户将其悬停时,光标变为指针(通过CSS)。
When the user click on the <button>
, the cursor of all the page should become wait
(via jQuery). 当用户单击<button>
,所有页面的光标都将变为wait
(通过jQuery)。
However, if the user keeps the cursor inside <button>
, it will stay as pointer
. 但是,如果用户将光标保留在<button>
,它将保持为pointer
。 How can I fix this ? 我怎样才能解决这个问题 ?
Live example : http://jsfiddle.net/URuLa/ 实时示例: http : //jsfiddle.net/URuLa/
Tested with Chrome 36.0.1985.125 (last version) 经过Chrome 36.0.1985.125测试(最新版本)
Add a class for html that sets the cursor and sets all elements to also have the wait cursor when html has that class 为html添加一个类,该类设置光标并将所有元素设置为在html具有该类时也具有等待光标
CSS 的CSS
html.wait, html.wait * {
cursor:wait;
}
then instead of doing 然后,而不是做
$('html').css("cursor","wait");
use addClass to add the wait class to html 使用addClass将等待类添加到html
$('html').addClass("wait");
Then when done just use removeClass to remove the class 然后在完成后,使用removeClass删除该类
You can change the cursor property for your button in the click
callback. 您可以在click
回调中更改按钮的游标属性。
$(document).ready(function(){
$("button").click(function() {
$('html').css('cursor','wait');
$(this).css('cursor','wait');
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.