<div>
<span>A</span>
<span>B</span>
<span>C</span>
<span>D</span>
</div>
If a user clicks on one of the spans within the div, I want to apply styles (such as text color) to that span and all preceding spans inside that same div. Additionally, I want to remove any previous styling applied to other clicked spans. The spans do not have any classes or IDs.
How can I achieve this functionality using jQuery?