将输入类型从文件更改为文本

时间:2016-07-09 08:50:51

标签: javascript jquery html

我的要求最初是我的输入类型应该是“文件”但它只读。因此,与选择文件一起,我应该能够在文本框中写入文件名。 有人可以帮忙吗?我应该写文件名,就像在文本框中写文字一样。

1 个答案:

答案 0 :(得分:0)



var change = document.getElementById("change");

    //Do whatever then call when you need it
$('#changer').click(function(){
  change.type = 'text';
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" id="change">
<br>
<button type="button" id="changer">Change Type</button>
&#13;
&#13;
&#13;