当前位置:网站首页>input显示当前选择的图片
input显示当前选择的图片
2022-07-04 05:16:00 【老板娘来碗面】
1.jsp代码
<div class="lf salebd">
<a href="#">
<img src="images/ad20.jpg" id="img" width="100" height="100"/></a></div>
2.js代码
$(function () {
$("#file").change(function () {
if (this.files.length) {
let file = this.files[0];
let reader = new FileReader();
//新建 FileReader 对象
reader.onload = function () {
// 当 FileReader 读取文件时候,读取的结果会放在 FileReader.result 属性中
document.querySelector('#img').src = this.result;
document.querySelector('#text').innerHTML = this.result;
};
// 设置以什么方式读取文件,这里以base64方式
reader.readAsDataURL(file);
}
})
})
3.效果
边栏推荐
- 补某视频网站的js,进行视频解密
- Easy change
- Daily question brushing record (12)
- c语言经典指针和数组笔试题解析
- left_and_right_net可解释性设计
- [matlab] general function of communication signal modulation bandpass filter
- Notepad++--显示相关的配置
- Ping port artifact psping
- SQL injection - injection based on MSSQL (SQL Server)
- Flink1.13 SQL basic syntax (I) DDL, DML
猜你喜欢
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
19.Frambuffer应用编程
Google Chrome browser will support the function of selecting text translation
拓扑排序和关键路径的图形化显示
补某视频网站的js,进行视频解密
LM small programmable controller software (based on CoDeSys) note XXI: error 3703
What are the reasons for the frequent high CPU of ECS?
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
Programming example of stm32f1 and stm32subeide -74hc595 drives 4-bit 7-segment nixie tube
VB.net GIF(制作、拆解——优化代码,类库——5)
随机推荐
Unity2D--人物移动并转身
How to configure static IP for Kali virtual machine
[matlab] matlab simulates digital baseband transmission system eye diagram of bipolar baseband signal (cosine roll off forming pulse)
2022g2 power station boiler stoker special operation certificate examination question bank and answers
VB. Net calls ffmpeg to simply process video (class Library-6)
Google Chrome browser will support the function of selecting text translation
Supplement the JS of a video website to decrypt the video
1480. Dynamic sum of one-dimensional array
光模塊字母含義及參數簡稱大全
Zzulioj:1201: mode problem
LM small programmable controller software (based on CoDeSys) note 22: error 4268/4052
left_and_right_net可解释性设计
[matlab] matlab simulation modulation system FM system
The data mark is a piece of fat meat, and it is not only China Manfu technology that focuses on this meat
VB. Net simple processing pictures, black and white (class library - 7)
2022年R2移动式压力容器充装复训题库及答案
LC周赛300
VB.net 调用FFmpeg简单处理视频(类库——6)
Automated testing selenium foundation -- webdriverapi
VB.net 简单的处理图片,黑白(类库——7)