Skip to content

Instantly share code, notes, and snippets.

@andxbes
Created October 31, 2023 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andxbes/78c037dc89524772bdb63943163adc54 to your computer and use it in GitHub Desktop.
Save andxbes/78c037dc89524772bdb63943163adc54 to your computer and use it in GitHub Desktop.
input_file.js
//Change label for file
jQuery(document).ready(function ($) {
let $file_container = $('.file-upload');
if ($file_container.length > 0) {
$file_container.each(function () {
let $container = $(this);
let $file_input = $container.find('.wpcf7-file');
let $label = $container.find('.file-label__text');
$file_input.change(function () {
var out = "";
if (this.files.length > 0) {
out = [].slice.call(this.files).map(function (f) { return f.name; }).join(", ");
}
$label.text(out);
});
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment