I want to ask you a CSS question. My English is not good, but I try to express it completely! Today I hope to change the background to red after clicking, and not to have the hover effect (now hover will turn yellow in the past). If I don’t use javascript and jquery and only use CSS, how can I do it?
Thank you all for watching in advance, I really need your help!
ex
$('.button').on('click',function(){
$(this).toggleClass('red');
})
.button {
width: 100px;
height: 100px;
border: 1px solid #222;
text-align: center;
}
.button:hover {
background-color: yellow;
}
.red {
background-color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="button">123</div>
<div class="button">123</div>