Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove css hover style

I have mark up that toggles the hover css style using this rule. When there's a checkbox inside the panel I want to remove the background image style. Is this possible? I've tried the following although it fails.

CSS:

   .StaffMode .day ul li.standard a:hover table {
        background:url("test.png"); 
    }

JS:

   $("li.test table li").hover(
        function () {
            if($(this).children(':checked')) {
              alert('need to remove the background image style');  // shows as expected
              $(this).children('a').removeClass('hover');  // this doesnt work?
            }
        }
    );
like image 325
James Radford Avatar asked Oct 05 '12 13:10

James Radford


1 Answers

What you need to do is put some restriction on your :hover rule, and have your JavaScript change the element so it no longer applies. Something like this:

.has-hover:hover
{
    /* do whatever */
}

And then your JavaScript does this:

$(this).children('a').removeClass('has-hover');

You can't remove the :hover but you can remove the has-hover class, and since the rule requires both, this will prevent the .has-hover:hover rule from being applied.

like image 153
KRyan Avatar answered Oct 03 '22 21:10

KRyan