I cant figure this out I am trying to listen and when a list item changes to the class 'active' it will prepend a span element to the link inside the list item.
My html is
<ul>
<li class="active">
<a href="#when">When should I water my terrarium?</a>
</li>
<li><a href="#where">Where did the bugs come from?</a></li>
</ul>
and my jQuery is
jQuery('.cat-sidebar .widget_text li').each(function() {
if(jQuery(this).hasClass('active')) {
jQuery('.cat-sidebar .widget_text li a').prepend('<span><i class="fas fa-angle-double-right"></i></span>');
}
});
how would I correctly do this so the final result when the li class is active will look like this
<ul>
<li class="active">
<a href="#when">
<span><i class="fas fa-angle-double-right"></i></span>
When should I water my terrarium?
</a>
</li>
<li><a href="#where">Where did the bugs come from?</a></li>
</ul>