I have this in my CSS:
.body {
width: 150px;
height: 40px;
padding: 20px;
background-color: rgba(255,0,0,1);
text-align: center;
border: 1px solid black;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
display: block;
top: 50px;
font-weight: bold;
font-size: 25px;
}
And I want to change the background-color
's opacity (alpha
) when the user clicks on a button:
<button onclick="lessColour()">-Colour</button>
How can I create this lessColour()
function so that everytime the user clicks on the button, the background-color
's alpha
is decreased 0.1
?
BTW, I have to do that with 3 different elements.