如何修改html input type file 的语言

情况描述:

在浏览器中,即使lang="en",文件输入框也会显示电脑的语言

如何修改:

思路:把原有的input框display:none,然后通过label触发对应功能,重新写入另一个div显示文件名。

<style>
	#id_for_file{
	display: none;
	}
	label{
		margin-top: 1rem;
		font-weight: bold;
		cursor: pointer;
	}
	label:hover{
		color: #b1dfbb;
	}
</style>
<body>
<label for="file">点我选择图片</label>
<input type="file" name="file">
<div id="display_file_name"></div>
</body>
<script>
	$("#id_for_file").change(function () {
		var filename = this.files[0].name;
		$("#display_file_name").html(filename)
		$("label[for='id_for_file']").attr("style","color:#b1dfbb")
	});
</script>
posted @ 2022-10-14 10:28  lisicn  阅读(503)  评论(0编辑  收藏  举报