之所以要做这件事,是为了做一个好看的上传按钮。
然后把文件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>