<a href="" tabindex="0">
    <label for="my_label" class="my_label" name="Upload" data-bind="attr: { for: 'uploadContent' + SubmissionId() }">
        <span>Upload Content</span>
    </label>
    <div class="hidden">
        <input type="button" id="my_label" class="fileupload" data-bind="event: { change: $parent.upload($data, $element, 'zip', false) }, attr: { id: 'uploadContent' + Id() }" accept="application/zip" type="file">
    </div>
</a>

在列表中,因此它是一个下拉列表。当我浏览下拉菜单并在“上传内容”上按Enter时,页面将刷新而不是打开文件。当我使用鼠标单击时,它可以正常工作。

如何在keypress Enter上打开文件系统?

最佳答案

您可以尝试如下放置href =“javascript:void(0)”而不是href =“”:

<a href="javascript:void(0)" tabindex="0">
   <label for="my_label" class="my_label" name="Upload" data-bind="attr: {   for: 'uploadContent' + SubmissionId() }">
    <span>Upload Content</span>
</label>
<div class="hidden">
    <input type="button" id="my_label" class="fileupload" data-bind="event: { change: $parent.upload($data, $element, 'zip', false) }, attr: { id: 'uploadContent' + Id() }" accept="application/zip" type="file">
</div>

10-07 19:02