This time I bring you jQueryUploadLocal priority preview before uploading pictures. What are the precautions for jQuery to preview locally before uploading pictures? The following are Let’s take a look at practical cases.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jquery上传图片本地预览效果</title> </head> <body> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <input id="upload" type="file"> <img id="preview" src=""> <script type="text/javascript"> $('#upload').change(function(){ // 获取FileList的第一个元素 alert(document.getElementById('upload').files[0]); var f = document.getElementById('upload').files[0]; src = window.URL.createObjectURL(f); document.getElementById('preview').src = src }) </script> </body> </html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
vue makes full selection and inverse selection functions
##vue.js element-ui tree tree shape How to modify iview
The above is the detailed content of jQuery previews locally before uploading images. For more information, please follow other related articles on the PHP Chinese website!