I have a like button, when you press the button it is supposed to change state. Im doing it with jQuery. When you click the button it changes color's and in ctrl+shift+i also classes however it doesnt change classes in ctrl+u+i which causes jQuery to not notice the change of classes. Essentialy the first time you click the button it will change color but than it will be static. Any idea how to fix it?
Here is my code:
$('.unclicked-like-button').click(function(){
$(this).removeClass('unclicked-like-button');
$(this).addClass('clicked-like-button');
})
$('.clicked-like-button').click(function(){
$(this).removeClass('clicked-like-button');
$(this).addClass('unclicked-like-button');
})
.unclicked-like-button {
color: black;
}
.clicked-like-button {
color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class = 'unclicked-like-button' id='like-button'> Like </button>