Emi*_*ily 1 javascript javascript-events
我有javascript代码,它复制输入文件的值,并在文本框中实时传递.
<script>
function copyit(){
var thephoto=document.getElementById('thephoto').value;
var fileonchange=document.getElementById('fileonchange').value;
if(!thephoto==fileonchange){
document.getElementById('fileonchange').value=thephoto;
}
}
window.setInterval("copyit()", 500);
</script>
Choose File : <input type="file" id="thephoto"><br>
Here Is the file name : <input type="text" id="fileonchange">
Run Code Online (Sandbox Code Playgroud)
遗憾的是,这只能工作一次,然后在再次更改文件时停止粘贴值.(我的意思是你应该重新加载页面再次工作)
是IF有缓存的东西?你可以自己试试看代码.
谢谢你们
语法错误.您需要!=运算符来表示不等式:
if (thephoto != fileonchange) {
Run Code Online (Sandbox Code Playgroud)
在!thephoto实际上逆其布尔表示(即true变false,反之亦然,也null变得true).在==实际上比较两个操作数的平等.
| 归档时间: |
|
| 查看次数: |
364 次 |
| 最近记录: |