Is there a method to apply a class that modifies rules for a child element using Javascript? I have successfully added it with CSS but am struggling to do the same with Javascript. Removing the class in JS is easy by referencing the classname before the hover pseudo-class, but re-adding it after removal doesn't seem to work properly. It could be a syntax issue, but I'm unable to find the correct solution. Any suggestions?
function hideTooltip(){
elementName.classList.remove('tooltip');
}
function showTooltip(){
elementName.classList.add('tooltip');
}
.tooltip:hover .tool-name{
display: inline;
}
UPDATE
Upon further review, it appears that it was indeed functioning correctly. The problem stemmed from some specificity issues preventing it from taking effect when trying to reapply it.