隐藏<input type="file"> 实现点击div或图片打开文件选择路径
HTML:
<input type="file" style="display:none" id="addfile-btn">
<div onclick="addfile()">点击上传图片</div>
JS:
<script>
function addfile() {
document.getElementById("addfile-btn").click();
}
</scrip>
如果一个页面需要多个这种事件的话,显然用ID是不太好的,那么就可以通过jQuery的prev来实现同级class查找,以此实现上传控件的调用。
HTML:
<input type="file" style="display:none" class="addfile-btn">
<div class="upload">点击上传图片1</div>
<div class="upload">点击上传图片2</div>
JS:
<script>
$(".upload").bind('click', function() {
$(this).prev(".addfile-btn").click();
});
</script>
隐藏<input type="file"> 实现点击div或图片打开文件选择路径的更多相关文章
- 上传文件 隐藏input type="file",用text显示
<div> <span>上传文件:</span> <input type="file" id="upload_file" ...
- 利用jquery来隐藏input type="file"
<li> <input type="text" name="token" value = "<?php ech$_SESSIO ...
- jquery的input:type=file实现文件上传
<!DOCTYPE html> <html> <head> <title>html5_2.html</title> <style> ...
- <input type="file">如何实现自定义样式
利用样式覆盖来实现效果:先看下原本和改变后的样式 1 <!doctype html> 2 <html> 3 <head> 4 <title>file自定 ...
- input type=file accept中可以限制的文件类型
在上传文件的时候,需要限制指定的文件类型. <input type="file" accept="image/*" /> accept表示可以上传文 ...
- input type=file accept中文件格式限制
原文链接:https://blog.csdn.net/usuallyuser/article/details/83060341 accept="application/msexcel,app ...
- <input type="file"> 标签详解
详见:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/file#attr-multiple 使用 type=" ...
- 自定义上传按钮 <input type="file" name = "file"/> (将file隐藏在button下)
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- python+selenium:解决上传文件<input type='file'>标签属性被css的visibility隐藏导致无法定位元素的问题
要想上传文件,需要找到在HTML中<input type="file" />这个标签,有它就可以利用send_keys上传文件,不过这里的<input>元素 ...
随机推荐
- tomcat JNDI 设置
一.在Spring配置文件中的配置 <bean id="dataSource" class="org.springframework.jndi.JndiObje ...
- Codeforces Round #288 (Div. 2) E. Arthur and Brackets
题目链接:http://codeforces.com/contest/508/problem/E 输入一个n,表示有这么多对括号,然后有n行,每行输入一个区间,第i行的区间表示从前往后第i对括号的左括 ...
- mongodb 释放磁盘空间
db.copyDatabase("from","to","127.0.0.1:16161"); 将127.0.0.1上的from库.拷贝到t ...
- h5的特点
关于HTML面试题汇总之H5 一.H5有哪些新特性,移除了哪些元素?如何处理h5新标签的浏览器兼容性问题,如何区分html和html5 1. html5不在是SGL(通用标记语言)的一个子集,而包 ...
- [codeforces 339]D. Xenia and Bit Operations
[codeforces 339]D. Xenia and Bit Operations 试题描述 Xenia the beginner programmer has a sequence a, con ...
- linux中comm命令用法
linux系统中comm命令用法详解 linux系统下的comm命令是一个非常实用的文件对比命令. comm命令功能: 选择或拒绝两个已排序的文件的公共的行. comm命令语法:comm [-12 ...
- 2015安徽省赛 H.数7
http://xcacm.hfut.edu.cn/problem.php?id=1212 模拟大发 #include<iostream> #include<cstdio> #i ...
- java抓取快递信息
package zeze; import java.io.IOException; import org.jsoup.Connection; import org.jsoup.Jsoup; impor ...
- faac编码aac
// faacode.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <faac.h> #include &l ...
- docker ui
docker run -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock uifd/ui-for-doc ...