$('#file').on('change', function () {
var parts = $(this).val().split('\\');
$('#filemask').val(parts[parts.length -1]);
}).change();
Copy input file text to new span & trim the value.
-
13-07-2023 - |
質問
I've styled a file input (making the opacity=0) but I would like to display the slected file in a new span. I've copied the input value and pasted it into a span with jquery:
$('#file').on('change', function () {
$('#filemask').val($(this).val());
}).change();
So, I'm getting this value: "C:\fakepath\file.txt". I'm not sure how to trim the first 12 characters from the value so that I'm just left with: "file.txt"
Thanks!
解決
所属していません StackOverflow