<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>简单实用的jQuery多尺寸图片上传预览代码</title>
<script src="js/jquery.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div class="box">
<p>上传log</p>
<p>
<div class="upload imgLog">
<span><i class="glyphicon glyphicon-open"></i>上传log0</span> </div>
</p>
<p>上传头像</p>
<p>
<div class="upload imgLog2">
<span><i class="glyphicon glyphicon-open"></i>上传头像</span> </div>
</p>
<p>上传海报</p>
<p>
<div class="upload imgLog3">
<span><i class="glyphicon glyphicon-open"></i>上传海报</span> </div>
</p>
</div>
<script src="js/index.js"></script>
<script>
$(function(){
var img1 = new ImgUpload('.imgLog',210,55,55);
var img2 = new ImgUpload('.imgLog2',100,100,100);
var img3 = new ImgUpload('.imgLog3',400,200,200);
$(document).on('change',".imgLog input",function(e){
//模拟后台返回url
var url = window.URL.createObjectURL(e.target.files[0]);
$(this).parent().css('background','url('+url+')0% 0% / cover')
console.log(window.URL.createObjectURL(e.target.files[0]))
img1.setSpan(this)
})
$(document).on('change',".imgLog2 input",function(e){
//模拟后台返回url
var url = window.URL.createObjectURL(e.target.files[0]);
$(this).parent().css('background','url('+url+')0% 0% / cover')
img2.setSpan(this)
})
$(document).on('change',".imgLog3 input",function(e){
//模拟后台返回url
var url = window.URL.createObjectURL(e.target.files[0]);
$(this).parent().css('background','url('+url+')0% 0% / cover')
img3.setSpan(this)
})
})
</script>
</body>
</html>
简单实用的jQuery多尺寸图片上传预览代码.zip
版权申诉
10 浏览量
2023-09-21
00:00:43
上传
评论
收藏 147KB ZIP 举报
码云笔记
- 粉丝: 2w+
- 资源: 5837
最新资源
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈