0
我需要按鍵事件附加到選擇的結果:
var inputElement = $(this).parent().find("input[myAttributeID]");
我知道如何通過從一個變種一個元素做函數附加我甚至不知道如何稱呼它
感謝
我需要按鍵事件附加到選擇的結果:
var inputElement = $(this).parent().find("input[myAttributeID]");
我知道如何通過從一個變種一個元素做函數附加我甚至不知道如何稱呼它
感謝
inputElement.on("keypress", function(oEvent) { });
//or
var inputElement = $(this).parent()
.find("input[myAttributeID]")
.on
(
"keypress",
function(oEvent)
{
if (oEvent.keyCode == 13)
{ /* whatever happens */ }
}
);
當按鍵事件發生時,你的函數將被調用。 從代碼中調用它來測試:
inputElement.trigger("keypress");
感謝,試圖找出我怎麼才能得到獲得鍵代碼13 – RollRoll
IF((oEvent.keyCode oEvent.keyCode:e.which)= = 13){/ *在此處輸入關鍵代碼* /}如果符合您對原始問題的要求,請標記爲答案。 :) –
jQuery規範'e.which',沒有理由在'event'中測試'keyCode'的存在。 – Ohgodwhy