I'm dying to solve my problem with autogenerated input in a span. I'm using the Wordpress plugin Contact Form 7 on my website and I want so animate the label while the user in using the input field.
When the input-field is on focus or something is typed in it, the class active should appear in the div with the class "grid-3".
I tried to get the javascript myself but it doesnt works:
$('.wpcf7-form-control-wrap').each(function() {
  //console.log($(this));
  $(this).on('focus', function() {
    $(this).parent().parent().addClass('active');
  });
  $(this).on('blur', function() {
    if ($(this).val().length == 0) {
      $(this).parent().parent().removeClass('active');
    }
  });
  if ($(this).val() != '') $(this).parent('.grid-3').addClass('active');
});
The HTML:
<div class="grid-3">
  <label for="schenkel2">Schenkel 2 in mm</label>
  <span class="wpcf7-form-control-wrap schenkel2">
    <input type="text" name="schenkel2" value="" size="40" class="wpcf7-form-control wpcf7-text" id="schenkel2" aria-invalid="false">
  </span>
</div>
:focuspseudo-class is made for just such an occasion - Jaromanda X