I'm trying to change the class of an html element i using jquery. What i'm trying to achieve is when the user clicks on div , I would like the CSS class of the i under the clicked div to change.
So far I'm unable to achieve this. Any tip will be appreciated.
$(document).ready(function() {
$('div.gen').click(function() {
$(this).next('span i').toggleClass('fa-angle-double-up fa-angle-double-down');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<li>
<div class="gen"><span>
<div class="inline-block"> 👨
<figcaption>John</figcaption>
</div>
<i class=" stack-top box arrow bounce fa fa-angle-double-down" style="font-size:24px"></i>
<div class="inline-block"> 👩
<figcaption>Jane</figcaption>
</div>
</span>
</div>
</li>
<hr>
<li>
<div class="gen"><span>
<div class="inline-block"> 👨
<figcaption>John2</figcaption>
</div>
<i class=" stack-top box arrow bounce fa fa-angle-double-down" style="font-size:24px"></i>
<div class="inline-block"> 👩
<figcaption>Jane2</figcaption>
</div>
</span>
</div>
</li>
Thanks