I have this code:
<script>
  function scaleDown() {
 
    $('.work > figure').removeClass('current').addClass('not-current');
    $('nav > ul > li').removeClass('current-li');
 
}
 
function show(category) {
 
    scaleDown();
 
    $('#' + category).addClass('current-li');
    $('.' + category).removeClass('not-current');
    $('.' + category).addClass('current');
 
    if (category == "all") {
        $('nav > ul > li').removeClass('current-li');
        $('#all').addClass('current-li');
        $('.work > figure').removeClass('current, not-current');
    }
 
}
 
$(document).ready(function(){
 
    $('#all').addClass('current-li');
 
    $("nav > ul > li").click(function(){
        show(this.id);
    });
 
});
</script>I have inserted it on this page "artissidou" and it's purpose is to filter the displayed images with animation. If I try to navigate to this page via the "contact us" page for example, the code doesn't work unless I refresh the page.
Is there a way to have the code work normally regardless of where I'm navigating from? I am a complete noob with js so please break down the steps for me.
 
     
    