I have a series of HTML li elements. In this scenario, if the 3rd li element is marked as active, then I would like to set the 1st and 2nd li elements as complete. To achieve this, I will first remove any existing classes from the 1st and 2nd li elements, and then add the complete class. Additionally, when the 3rd li element has the active class, I want the 4th li element to be half-complete. Lastly, the last li element should not have any class associated with it.
<ul>
<li class="complete">Coffee</li>
<li class="complete">Tea</li>
<li class="active">Milk</li>
<li class="half-complete">Milk</li>
<li>Milk</li>
</ul>