Search code examples
jquerycssattrremoveclass

Remove style property using jquery


I have this style property in my css file:

.table tbody tr:hover th,
.table tbody tr:hover td { background: #d1e5ef; }

I would like to remove this via jquery, how would I go about doing this? I tried removeClass and attr but doesnt work.


Solution

  • You need to add some more css to make this work:

    .table tbody tr:hover th,
    .table tbody tr:hover td { background: #d1e5ef; }
    
    .table tbody tr.no-hover:hover th,
    .table tbody tr.no-hover:hover td { background: inherit; }
    

    You would add the class .no-hover using $(selector).addClass('no-hover'). This will style them differently than the other :hover definitions you have. You may have to use an explicit color to make this work.