例如設定熱鍵,我有一個像輸入標籤:JS - 上上傳文件
<input type="file" id="upload" multiple="true">
這是可以通過設置熱鍵,而不是點擊輸入元素上選擇文件?
例如設定熱鍵,我有一個像輸入標籤:JS - 上上傳文件
<input type="file" id="upload" multiple="true">
這是可以通過設置熱鍵,而不是點擊輸入元素上選擇文件?
$(document).on("keydown", function(e){
e = e || window.event;
var keyCode = event.keyCode; // code of the key pressed
if(e.ctrlKey){ // if control key is pressed
if(keyCode == 13){ // if current key is "enter" key
$("input[type='file']").trigger("click"); // trigger click event
}
}
});
我發現了這個問題。只是因爲它觸發我的網站上的所有'input [type ='file']':)。謝謝。 – Lewis
您的歡迎。 –
使用document.keyup
檢查出這個fiddle,試着點擊CTRL + I
的可能重複[使用觸發器文件上傳對話框的JavaScript/jQuery的(http://stackoverflow.com/questions/4502612/trigger-file- upload-dialog-using-javascript-jquery) – undone