Created
August 20, 2019 07:53
-
-
Save wireinet/1a5d51466e049e3ce1728298e3f085e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// attach file | |
(function() { | |
'use strict'; | |
$('.input-file').each(function() { | |
var $input = $(this), | |
$label = $input.next('.js-labelFile'), | |
labelVal = $label.html(); | |
$input.on('change', function(element) { | |
var fileName = ''; | |
if (element.target.value) fileName = element.target.value.split('\\').pop(); | |
fileName ? $label.addClass('has-file').find('.js-fileName').html(fileName) : $label.removeClass('has-file').html(labelVal); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment