if(('#btn1').css("background-color")== "green")
function vote(str){
if(str==1){
if(('#btn1').css("background-color")== "green"){
$('#btn1').css("background-color","");
}else{
$('#btn1').css("background-color","green");
}
}else{
$('#btn2').css("background-color","red");
}
}
</script>
</head>
<body>
<button id="btn1" onclick="vote(1)" >Up Vote</button>
<button id="btn2" onclick="vote(2)" >Down Vote</button>
$("button").on("click", (e) => {
$(e.target).toggleClass("transparent green")
})
.green {
background-color: green;
}
.transparent {
background-color: rgba(0, 0, 0, 0);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="transparent">hello</button>
$("#btn1").on("click", function() {
$(this).toggleClass('background-green');
});
$("#btn2").on("click", function() {
$(this).addClass('background-red');
});
.background-red {
background-color: red !important ;
}
.background-green {
background-color: green !important;
}
.background-transparent {
background-color: transparent;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="btn1" class="background-transparent">Up Vote</button>
<button id="btn2">Down Vote</button>