I have a table that shows name, rank, and points. Rows change color when I hover over them and When I click on each individual row, it adds the class of 'active'. My CSS rules select the 'active' class to give it a border and new background color. The border works, but the background color doesn't.
I know the jquery is working because when I click on the row, it adds a black border as it should according the CSS rules I set, but the background just turns and stays plain white. I checked firebug too which shows the active class being added to the clicked row but the color still doesn't change. I'm not worried about toggle clicking right now because I just want to get this first step cleared.
I searched a few other older posts that recommended adding !important, but that's not working either.
Html
<tr class="row-data">
<td class="name">player</td>
<td class="points">points</td>
<td class="rank"><p id="rank">Rank1</p></td>
</tr>
css
.row-data .active {
border: 2px solid black;
background-color: red !important;
}
Jquery
$(function() {
var limegreen = '#73f302';
var white2 = '#eef4cc';
var transitionTime = '0.5s'
var $rankTable = $('.rank-table');
var $rowData = $rankTable.find('.row-data');
function rowHighlight() {
var rowID = $(this)
rowID.css({
'background-color': limegreen,
'transition-property': 'background-color',
'transition-duration': transitionTime,
});
};
function rowDelight() {
var rowID = $(this)
rowID.css({
'background-color': white2,
'transition-property': 'background-color',
'transition-duration': transitionTime,
});
};
function activeToggle() {
var activeID = $(this)
activeID.addClass('active')
};
$rowData.on('mouseover', rowHighlight);
$rowData.on('mouseleave', rowDelight);
$rowData.on('click', activeToggle);
});
.row-data .activewhen by your code i guess you should be targeting.rank-table .activeor.row-data.active