Here is My jQuery Code:
$('a#cusine1').on('click', function(){
$('div#product-list').html("LOADING..........").show();
$(".ccid").addClass("0");
document.getElementById("ccid1").className="active2";
});
$('a#cusine2').on('click', function(){
$('div#product-list').html("LOADING..........").show();
$(".ccid").addClass("0");
document.getElementById("ccid2").className="active2";
});
$('a#cusine3').on('click', function(){
$('div#product-list').html("LOADING..........").show();
$(".ccid").addClass("");
document.getElementById("ccid3").className="active2";
});
This is the HTML CODE I'm Using:
<li id="ccid1" class="ccid">
<a href="#" id="cusine1"><i class="fa fa-ticket"></i>3 Star Hotel</a> </li>
<li id="ccid2" class="ccid">
<a href="#" id="cusine2"><i class="fa fa-ticket"></i>3 Star Hotel</a> </li>
<li id="ccid3" class="ccid">
<a href="#" id= "cusine3"><i class="fa fa-ticket"></i>5 Star Hotel</a>
</li>
The Desired Output Should Be:
When li
with the id "ccid1" is clicked, the class "active2" should be added. All other li
elements should only have the "ccid" class.
The number of li
items may vary depending on PHP.
An Issue Found:
Upon the first click on the li
item with the id "ccid1", the class "active2" is successfully added. However, if then clicking on the li
element with the id "ccid2", the class "active2" gets added, but the li
with the id "ccid1" does not get set to "0".