0

I have a script, with two jQuery click functions in. The first one works perfectly, but the second doesn't work at all. Even though they follow similar code pretty much, just with different selectors. Anyone got any ideas? Thanks in advance!

<script type="text/javascript">
jQuery('li.inactive').click(function() {
    var letter = jQuery(this).attr("id");
    jQuery('li.active').addClass('inactive');
    jQuery('li.active').removeClass('active');
    jQuery(this).removeClass('inactive');
    jQuery(this).addClass('active');
    jQuery('div.profile-mini').hide();
    jQuery("div#" + letter).show();
});
jQuery('li.active').click(function() {
    jQuery(this).removeClass('active');
    jQuery(this).addClass('inactive');
    jQuery('div.profile-mini').show();
});
Jake
  • 45
  • 5
  • You need to use delegated event handlers as the events are bound when the page loads, yet you change the classes after that. See the duplicate for more information – Rory McCrossan Jul 29 '20 at 12:41
  • 1
    @RoryMcCrossan thank you! Got it working now. Much appreciated. – Jake Jul 29 '20 at 13:36

0 Answers0