How can I create a click handler in jQuery to change the color of an 'eyebrow' element above a Heading element? The eyebrow element is set up with a pseudo element in my project, and I'm struggling to make it change color when the heading is clicked. Any suggestions or ideas would be greatly appreciated.
You can find the codepen link here: https://codepen.io/jon424/pen/poVYPzr
jQuery(function() {
changeColor()
});
function changeColor() {
$('#main').on("click", function() {
$('.main__heading:before').css("background-color", "red");
})
}
.padding {
border : 1px solid red;
padding : 40px;
}
#main:hover {
cursor : pointer;
}
.main__heading:before {
align-items : baseline;
background-color : green;
content : "";
display : flex;
height : 5px;
left : 0;
top : 0;
width : 70px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="padding">
<div class="main__heading">
<h1 type="button" id="main">Heading Text</h1>
</div>
</div>