javascript - How to override css cursor property of a hovered button? - Stack Overflow

I have a <button>, when the user hover it, the cursor bee pointer (via CSS).When the user click o

I have a <button>, when the user hover it, the cursor bee pointer (via CSS).

When the user click on the <button>, the cursor of all the page should bee wait (via jQuery).

However, if the user keeps the cursor inside <button>, it will stay as pointer. How can I fix this ?

Live example : /

Tested with Chrome 36.0.1985.125 (last version)

I have a <button>, when the user hover it, the cursor bee pointer (via CSS).

When the user click on the <button>, the cursor of all the page should bee wait (via jQuery).

However, if the user keeps the cursor inside <button>, it will stay as pointer. How can I fix this ?

Live example : http://jsfiddle/URuLa/

Tested with Chrome 36.0.1985.125 (last version)

Share Improve this question asked Jul 24, 2014 at 3:29 lepixlepix 4,9906 gold badges43 silver badges53 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Add a class for html that sets the cursor and sets all elements to also have the wait cursor when html has that class

CSS

html.wait, html.wait * {
   cursor:wait;
}

then instead of doing

$('html').css("cursor","wait");

use addClass to add the wait class to html

$('html').addClass("wait");

JSFiddle Demo

Then when done just use removeClass to remove the class

You can change the cursor property for your button in the click callback.

$(document).ready(function(){
    $("button").click(function() {
        $('html').css('cursor','wait');
        $(this).css('cursor','wait');
    });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744367815a4570795.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信