如何点击a标签实现弹出input file上传文件对话框

发布时间:2022-04-12 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了如何点击a标签实现弹出input file上传文件对话框脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
htML

复制代码
代码如下:

<SPAN class=tag><<SPAN class=tITle>div</SPAN>></SPAN>
<SPAN class=tag><<SPAN class=title>a</SPAN> <SPAN class=attribute>href</SPAN>=<SPAN class=value>"###"</SPAN>></SPAN>添加图片<SPAN class=tag></<SPAN class=title>a</SPAN>></SPAN>
<SPAN class=tag><<SPAN class=title>input</SPAN> <SPAN class=attribute>tyPE</SPAN>=<SPAN class=value>"file"</SPAN> <SPAN class=attribute>name</SPAN>=<SPAN class=value>"image"</SPAN> <SPAN class=attribute>class</SPAN>=<SPAN class=value>"hidden"</SPAN> <SPAN class=attribute>value</SPAN>=<SPAN class=value>""</SPAN> /></SPAN>
<SPAN class=tag></<SPAN class=title>div</SPAN>></SPAN>

css

复制代码
代码如下:

<SPAN class=class>.hidden</SPAN> <SPAN class=rules>{
<SPAN class=rule><SPAN class=attribute>display</SPAN>:<SPAN class=value> none;</SPAN></SPAN>
<SPAN class=rule>}</SPAN></SPAN>


复制代码
代码如下:

jquery
$('a').on('click', function(e) {
e.preventDefault();
$(this).closest('input[type=file]').trigger('click');
})

脚本宝典总结

以上是脚本宝典为你收集整理的如何点击a标签实现弹出input file上传文件对话框全部内容,希望文章能够帮你解决如何点击a标签实现弹出input file上传文件对话框所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。