I want to have click effect using jquery. When I click the first time, it changes the condition. When I click the object the second time or click other places, it returns to the original . I make it changed background color the first time, but how on 2nd time?
$(document).ready(function(){
$('.fas').on('click', function(){
$(this).css({
'background-color': 'white',
"color": '#40415a'
});
});
});
*{
padding: 0;
margin: 0;
}
body{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #40415A;
}
i.fa-mouse-pointer{
font-size: 60px;
display: flex;
align-items: center;
justify-content: center;
color: white;
background: #40415A;
border: 1px solid #fff;
padding: 40px 100px 40px 100px;
transition: .3s;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"
rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<i class="fas fa-mouse-pointer"></i>
<script src="script.js"></script>
</body>
</html>