之因此要作这件事,是为了作一个好看的上传按钮。code
而后把文件input给隐藏了,经过这个自定义的按钮来呼出上传窗口图片
<input type="file" id="fileInput" value="上传" > <input type="button" id="customInput" value="自定义样式按钮" onclick="TriggerOtherInputOnClickEvent()">
<script> function TriggerOtherInputOnClickEvent() { document.getElementById("fileInput").click(); } </script>
<style> #customInput { border-radius: 25px; width:140px; height:50px; border:1px; background-color: #FF702A; } #fileInput { display:none; } </style>