Here is the HTML content I am working with:
<li class="info"> info<li>
<li class="other"> info<li>
<li class="other"> info<li>
<li class="Error"> error<li>
<li class="other"> error<li>
<li class="warning"> warning<li>
<li class="other"> warning<li>
<li class="other"> warning<li>
<li class="info"> info<li>
<li class="other"> info<li>
<li class="other"> info<li>
To filter only the immediate li.other
elements based on the li
element class, I tried using jQuery.
My initial approach was to select .info
elements and then target previous siblings with class .other
:
$('.info').prevAll('li.other').css({});
However, this changed all the previous li.other
elements. Instead, I want to change only the specific li.other
element that comes immediately before the selected .info
element and ignore the rest.
If anyone has a suggestion for achieving this, please provide your input. Thank you!