【问题标题】:Change the default style of input file and change the text after select a file更改输入文件的默认样式并在选择文件后更改文本
【发布时间】:2014-12-27 01:11:54
【问题描述】:

我想更改输入文件的默认样式,我搜索了 SO 并找到了 solutionhttp://jsfiddle.net/younyzhU/6v8uL2co/

<div id=customOrth style="position: absolute; left:0; top:0px; ">
<button><label for="inputFile" style="padding-left: 0px;">
<a >choose orthology File</a></label></button>
<input style="display: none;" type="file" id="inputFile">
</div>

但是当我选择一个文件时,我需要将标签更改为选择的文件名,我该怎么办? 默认输入文件,将在选择文件后显示您选择的文件名。 谢谢!

【问题讨论】:

    标签: javascript jquery css file input


    【解决方案1】:

    这个答案应该对你有帮助,https://stackoverflow.com/a/1299069/3066711

    应该像这样简单。

    $("#inputFile").on("change", function(data) { $("label[for=inputFile]").text($(this).val())});
    

    【讨论】:

      猜你喜欢
      • 2013-05-07
      • 2011-07-05
      • 2017-11-05
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      • 1970-01-01
      • 2020-09-22
      相关资源
      最近更新 更多