I have group of unordered list. I have create some function that make every list is clicked, it will run a JS Function. Now I want to add some css, if the list is clicked, its bg color will changed. My code so far:
function getDealsTable(obj) {
var tenor = obj.innerHTML;
$(this).closest('li').css('background-color: rgba(86, 142, 175, 1) !important');
$(this).closest('li').siblings('li').css('background-color: rgba(15, 86, 132, 1) !important');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class='tenors'>
<li onclick='getDealsTable(this);'>12x</li>
<li onclick='getDealsTable(this);'>24x</li>
<li onclick='getDealsTable(this);'>36x</li>
<li onclick='getDealsTable(this);'>48x</li>
</ul>
Unfortunately it doesn't works. I have tried to change it to a class, but still not working. Anyone can help me? Thanks