Home > Web Front-end > JS Tutorial > body text

jQuery can give priority to local preview when uploading images

php中世界最好的语言
Release: 2018-06-12 15:16:29
Original
1345 people have browsed it

This time I will bring you jQuery to give priority to local preview when uploading images. What are the precautions for jQuery to give priority to local preview when uploading images? The following is a practical case, let's take a look.

<!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>
Copy after login

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:

How to use vue parent component to call child components (with code)

vue iView exports excel table

The above is the detailed content of jQuery can give priority to local preview when uploading images. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!