文件上传框的自定义
2016-02-29 17:53
176 查看
<input style="display: none;" id="photo" type="file" name="photo" accept="image/*" /> <p style="font-size: 40px;" onclick="selectPhoto()">拍照</p> <img id="photoimg"/>
$(function(){ $("#photo").change(function(e){ var file = e.target.files[0]||e.dataTransfer.files[0]; if(file){ var reader = new FileReader(); reader.onload=function(){ $("#photoimg").attr("src",this.result); } reader.readAsDataURL(file); } }); }); function selectPhoto(){ $("#photo").click(); }
如此一来,可以通过点击p标签来选取文件了,可以把p标签自定义成其他样式
相关文章推荐
- Zookeeper实现集群和负载均衡---(2)方案改造
- ORA-01157 rac挂了
- 让图片有不规则的轮廓
- Missing iOS Distribution signing identity for...的问题 或者 ERROR ITMS-90034: "Missing or invalid signature. 问题解决方法
- anjular js 表达式
- loadrunner 在 Control 执行的时候查看 每一个用户的执行日志
- 查看Mac电脑的开机记录
- Windows2008-2012和之后的系统改远程管理端口
- Windows server 08R2 IIS7 创建FTP 包括ftp的账号密码设置
- 向已知信号添加噪声——matlab仿真
- 11g 10g rac 停库方法、步骤
- NSCondition 多线程解决生产者消费者问题
- 如何保证Android Service在后台不被Kill,或者被Kill后重启
- Android 中 Environment.getExternalStorageDirectory()无效
- bootstrap 预定义样式风格
- 轻松应对C10k问题
- iOS原生获取当前连接的wifi名字
- 欢迎使用CSDN-markdown编辑器
- WEB开发者必备的7个JavaScript函数
- 九度题目1052