Hide and element and show another element

Hide and element and show another element

Hi,

In my jQuery code I want to achieve that by clicking a link one element replaces another element:


Now the problem is that if I click the link (" Click me to swap"), the visible element fades out but the hidden element which should show, doesn't show.

This is the jQuery function:

  1. function upload() {
  2.   var i = 0;
  3.   $('#upload').on('click', function() {
  4.     i++;
  5.     $('.upload-wrapper__item__icon-container--upload#' + i).remove();
  6.     $('this').closest('.upload-wrapper__item__icon-container--file').show();
  7.   });
  8. }

What is my mistake?

Thanks