If input has a value, hide label

If input has a value, hide label

Hi,

I'm trying to achieve that if an input-box has a value it's label should hide.
Please have a look at my example on CodePen:


The part which is not working is this:

  1. if ($(this).val() !='') {
  2.         $(this).closest('.form-label').hide();
  3.       }

What is wrong with my code?

Thanks