修改input框中type=file的样式

将input框中的file类型修改为点击图片来完成选择文件上传
直接看代码

<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>

		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	</head>

	<body>
		<img id="img" src="img/3.jpg" />
		<input style="display:none;" id="file" type="file" />
		<script>
			$(document).ready(function() {
				$('#img').click(function() {
					$('#file').click();
				});
			});
		</script>
	</body>

</html>

效果图就不放了
大家根据需求自行进行修改

发布了22 篇原创文章 · 获赞 2 · 访问量 426

猜你喜欢

转载自blog.csdn.net/jianchenn/article/details/105731124