jQuery实现上传图片前预览效果功能
时间:2021-03-25 09:18:52|栏目:jquery|点击: 次
网上很多代码实现了上传图片这个功能,但不支持实时预览图片,下面实现了上传图片前预览效果功能,具体如下
效果如图:

代码如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery上传图片之前可以预览效果</title>
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<input id="file" ;="" onchange="c()" type="file"><br>
<img src="" id="show" width="200"><script>
function c () {
var r= new FileReader();
f=document.getElementById('file').files[0];
r.readAsDataURL(f);
r.onload=function (e) {
document.getElementById('show').src=this.result;
};
}</script>
</body>
</html>
栏 目:jquery
下一篇:jQuery1.9.1针对checkbox的调整方法(prop)
本文标题:jQuery实现上传图片前预览效果功能
本文地址:http://www.codeinn.net/misctech/87651.html






