解决 html input file onchang 事件触发一次后失效问题

来源:互联网 发布:淘宝客下载安装 编辑:程序博客网 时间:2024/06/05 03:50

JS:
$(function(){    $("#userFile").change(function(){        batchImportUser();    });})
function batchImportUser(){    alert(1);    $("#userFile").replaceWith('<input style="opacity: 0;z-index:9999999;position: relative;left: -145px;" id="userFile" name="file" type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" value="导入用户" class="sureBtn sureBtnEx marginL20"/>');      $("#userFile").on("change", function(){          batchImportUser();    });  }

HTML:
<input style="opacity: 1;z-index:9999999;position: relative;left: -145px;" id="userFile" name="file" type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel" value="导入用户" class="sureBtn sureBtnEx marginL20"/>


转载地址:http://blog.csdn.net/wc0077/article/details/42065193

阅读全文
0 0
原创粉丝点击