Select 所有 (Ctrl+a) 键盘按钮不适用于 HTML5 可排序的输入字段

Select all (Ctrl+a) keyboard button not working for input filed inside the HTML5 sortable

我使用了 this HTML5 sortable plugin for drag-drop. Inside that draggable section, I've editable text filed. At the time of editing, when I tried to select all text of input field by keyboard command ctrl + a, I noticed that the text had not been selected. At first, I don't understand what's the problem. For testing, I put a normal textarea inside sortable content and noticed that also not works! So, this is the issue of HTML5 sortable plugin. Here is my fiddle,您可以看到第一个可编辑文本的 input(即 "Sortable Content start:" 文本的 outside/above)正在通过 ctrl + 命令工作可排序内容中剩余的 input 字段不适用于 ctrl + a。我该如何解决这个问题?

将此添加到您的代码中即可:

$('.section-sortable').keydown(function(e){
    if (e.keyCode == 65 && e.ctrlKey) {
        e.target.select()
    }

})

它基本上会监听您所在部分的 keydown 事件,如果 keydown 检测到 Ctrl-A,它 "selects" 目标。

Fiddle