首页 > 其他分享 >如何修改html input type file 的语言

如何修改html input type file 的语言

时间:2022-10-14 10:34:16浏览次数:48  
标签:id html file input label display

情况描述:

在浏览器中,即使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>

标签:id,html,file,input,label,display
From: https://www.cnblogs.com/lisicn/p/16790808.html

相关文章