简体   繁体   English

将锚点标记中的输入类型文件用于下拉项目

[英]Using input type file in the anchor tag for a dropdown-item

I am trying to use the input type file in one of my drop down item which is in the anchor tag. 我正在尝试在锚标记中的一个下拉项中使用输入类型文件。

So, Here my code is like , 所以,这里我的代码就像

 <div className="dropdown-menu actions-text">
     <a className="dropdown-item" href="#" onClick={e => props.viewJob(e, item.id, item.jdName)}>
         <i className="fa fa-envelope mr-2 view-icon" />
         View JD
     </a>
     <a className="dropdown-item" href='#'>
         <i className="fa fa-cloud-upload mr-2 upload-icon" aria-hidden="true" />
         Upload Resume
     </a>
     <input type='file' title="" onChange={(e) => { props.uploadResumeFolder(e, item.id, item.jdName) }}
            directory="" webkitdirectory="" mozdirectory="" allowdirs="" multiple />
     <a className="dropdown-item" href="#"><i className="fa fa-download mr-2 download-icon" aria-hidden="true" />
         Download Tracker</a>
</div>

but here if I add one more option at the top then the next one is getting clicked for that file option. 但是在这里,如果我在顶部再添加一个选项,则单击该文件选项的下一个。 always taking the second one by default. 默认情况下始终选择第二个。

So, How can I resolve this ? 那么,我该如何解决呢?

Have you tried doing something similar to this? 您是否尝试过做类似的事情?

<a href="#" onClick="(function(e){
    console.log('clicking', e);
    document.getElementById('X1').click();
})();">click here</a>

<input hidden type='file' title="" onChange="(function(e){
    console.log('changed file input', e)
})();" id="X1" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每次选择或单击下拉项时如何使用 AJAX Post 方法执行发送请求 - How to execute send request using AJAX Post method everytime I select or click the dropdown-item 如何使用 jquery 获取所选引导程序下拉项的值? - How do I get the value of a selected bootstrap dropdown-item using jquery? 从生成的引导程序下拉菜单中查找下拉项 - Find dropdown-item from generated bootstrap dropdown-menu Bootstrap btn-group dropdown click dropdown-item - Bootstrap btn-group dropdown click dropdown-item 选择下拉项时,表单文本字段变为可见 - Form Text Field becomes visible when dropdown-item is chosen 哪个 dom 元素将在引导下拉项之外工作以显示基于打开下拉列表的默认图像? - which dom element will work outside bootstrap dropdown-item to display an default image based on open dropdown? Bootstrap 4:单击下拉项时如何关闭下拉菜单? - Bootstrap 4: How Do I Close a dropdown-menu when a dropdown-item is clicked? 输入标签类型文件 - Input tag type file Bootstrap:选择下拉项目时导航链接不会隐藏 - Bootstrap: nav-link does not get hidden when dropdown-item is selected 如何使用打开jQuery模式对话框 <input type=“button”> 而不是锚标签? - How to open jQuery modal dialog using <input type=“button”> instead of anchor tag?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM