jQuery - find element in parent with closest()

0 votes
177 views
added Jul 9, 2019 in jQuery by LC Marshal Captain (25,790 points)
var iInputs = $('.i-form .input.animate input, .i-form .input.animate textarea');
iInputs.each(function() {
  if ($(this).val().length !== 0) {
    $(this).closest('.input').addClass('focused');
    // console.log('focus');
  }
});

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...