上传文件按钮隐藏及美化处理
星期一, 2019-08-12 | Author: Lee | html5 | 2,370 views
1.上传文件的按钮一直都是系统默认感觉不好看,可以通过下面两种方式调节
1.1 通过绑定click事件进行后续处理
1.2 为样式隐藏 如下
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>upload</title> </head> <body> <script type="text/javascript"> function clp(){ return document.getElementById('fileIa').click(); } function up(){ var file = document.getElementById("file").files[0], form = new FormData(), req = new XMLHttpRequest(); form.append("file", file); req.onreadystatechange = function() { if(req.readyState === 4 && req.status === 200) { // 回调函数 } req.open("post", 'URL', true); req.send(form); } </script> <a href="javascript:clp();">clp</a> <input type="file" name="fileIa" id="fileIa" style="display: none;"> <p>第二种</p> <style> #uploadImg{overflow:hidden; position:absolute} #handfile{ position:absolute; z-index:100; opacity:0;filter:alpha(opacity=0);} </style> <span id="uploadImg" title="上传图片和文件等"><input type="file" id="handfile" size="1" ><a href="javascript:;" title="上传图片文件等">upload</a></span> </body> </html> |
文章作者: Lee
本文地址: https://www.pomelolee.com/1904.html
除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址
No comments yet.
Leave a comment
Search
相关文章
热门文章
最新文章
文章分类
- ajax (10)
- algorithm-learn (3)
- Android (6)
- as (3)
- computer (85)
- Database (30)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (5)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (186)
- linux (143)
- mac (10)
- movie-music (11)
- pagemaker (36)
- php (50)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (6)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (2)
- 低代码 (1)
- 体味生活 (40)
- 前端 (21)
- 大数据 (8)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)