HTML5图片上传预览,手机端
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8" /> <meta name="author" content="EdieLei" /> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport"> <title>HTML5 图片上传预览</title> <style> #photo{ width:100px; height:100px; margin:auto; margin-top:100px; background:#0cc; border-radius:100px;} #photo img{ width:100px; height:100px; border-radius:50px;} </style> <script src="js/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('#img').change(function() { var file = this.files[0]; var r = new FileReader(); r.readAsDataURL(file); $(r).load(function() { $('#photo').html('<img src="' + this.result + '" alt="" />'); }) }) }) </script> </head> <body> <h3>HTML5 图片上传预览</h3> <input id="img" type="file" accept="image/*" /> <div id="photo"></div> </body> </html>
相关推荐
wusiye 2020-10-23
表格的现在还是较为常用的一种标签,但不是用来布局,常见处理、显示表格式数据。在HTML网页中,要想创建表格,就需要使用表格相关的标签。<table> <tr> <td>单元格内的文字</td> ...
gufudhn 2020-08-09
nercon 2020-08-01
swiftwwj 2020-07-21
nercon 2020-07-16
饮马天涯 2020-07-05
Lophole 2020-06-28
gufudhn 2020-06-12
csstpeixun 2020-06-11
huzijia 2020-06-09
WebVincent 2020-06-06
行吟阁 2020-05-30
qsdnet我想学编程 2020-05-26
gufudhn 2020-05-25
qsdnet我想学编程 2020-05-19
suixinsuoyu 2020-05-15
HSdiana 2020-05-15
PioneerFan 2020-05-15