您的位置:首页 > Web前端 > JavaScript

JS触发file类型Input的onclick()

2016-03-23 16:05 459 查看
之所以要做这件事,是为了做一个好看的上传按钮。

然后把文件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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息