JSFiddle - React, Tailwind, and code Playground
HTML
<script>
window.onload = function(){
var color = "red",
setcolorLink = document.getElementById("setcolor");
setcolorLink.onclick = function(){
this.setAttribute("data-value", color);
};
}
</script>
<a id="setcolor" class="colors" href="javascript:void(0)" role="button" data-value="mycolor">Choose color</a>