需求

解决方案
利用lable标签和input进行绑定,更改lable的样式,触发input事件
<form id="myform" action="/device/excel/import.htm", method="post" , enctype="multipart/form-data" style="float: right;" >
<%--通过label标签与input标签绑定--%>
<label for='my_file' class='inputlabelBox' >
<a class="btn btn-submit" href="javascript:function_select_file();"><i class="glyphicon glyphicon-export"></i>上传资产信息</a>
</label>
<input type="file" name="file" onchange="change(event)" style="float: right; width: 200px; height: 35px; display:none;" id="my_file" />
</form>

这篇博客介绍了如何利用HTML的label元素与input元素进行绑定,以创建一个美观的文件上传按钮。通过更改label样式并监听input的onchange事件,可以实现文件选择后的样式变化,从而提供用户友好的上传体验。

被折叠的 条评论
为什么被折叠?



