JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<div class="arrow-up"></div>
<h5 id="myid">3</h5>
<div class="arrow-down"></div>
<h1>Desired Results</h1>
when you upvote
<div class="arrow-up"></div>
<h5 style="color:pink;">4</h5>
<div class="arrow-down"></div>when you downvote
<div class="arrow-up"></div>
<h5 style="color:pink;">2</h5>
<div class="arrow-down"></div>
CSS
.pink {
color: pink;
}
.arrow-up {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 20px solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
}
h5 {
position:relative;
font-size:30px;
left:12px;
}
}
JavaScript
function changeColor1() {
document.getElementById("myid").className = "pink";
}
function init() {
document.getElementById("myid").onclick = changeColor1;
}
window.onload = init();