开发者

How to use .removeClass() to disable jquery function

I want the button click to remove the class "hover-on" so that the hover function becomes disabled, but once the DOM loads it rem开发者_如何学Gooves the class, but the hover function still works.

I am using the following code.

//Click this 
$('button').click(function() {
    $('#main-div').removeClass('hover-on');
});

//Remove class to disable this hover function
$('.hover-on').hover(function() {
    blah blah blah
});


The event doesn't have anything with the CSS class. You need to unbind the event:

$('button').click(function() {
    $('#main-div').removeClass('hover-on').unbind("hover");
});

$('.hover-on').hover(function() {
    blah blah blah
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜