on my website, I have a few elements which have tooltips. Now, the way I am handling the tooltips is by using pure css and an attribute. The code below should help you understand:
.my-container [tooltip]:before {
bottom: 25%;
font-weight: 600;
border-radius: 2px;
background: #585858;
color: #fff;
content: attr(tooltip);
font-size: 12px;
visibility: hidden;
opacity: 0;
padding: 5px 7px;
margin-right: 12px;
position: absolute;
right: 100%;
white-space: nowrap;
}
.my-container [tooltip]:hover:before,
.my-container [tooltip]:hover:after {
visibility: visible;
opacity: 1;
}
<div class="my-container">
<a href="#" class="buttons" tooltip="Submit form">Submit</a>
</div>
This works nicely enough. Now, I want to change the css style of the tooltip dynamically using jQuery. To do this, I am trying the following code:
$('.my-container [tooltip]:before').css({
'color' : 'red'
});
However, nothing changes. How can I do this using jQuery?