jQuery实现上传图片前预览效果功能

这篇文章主要为大家详细介绍了jQuery实现上传图片前预览效果功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

网上很多代码实现了上传图片这个功能,但不支持实时预览图片,下面实现了上传图片前预览效果功能,具体如下

效果如图:

jQuery实现上传图片前预览效果功能

代码如下:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>jQuery上传图片之前可以预览效果</title> <script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script> <style> </style> </head> <body> <input ;="" onchange="c()" type="file"><br> <img src=""><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>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydpdz.html