簡體   English   中英

jQuery提示消息不適用於輸入鍵事件

[英]jquery prompt message not working on enter key event

case 'confirmyesno':
    $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.yesButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.noButton + '" id="popup_cancel" /></div>');
    $("#popup_ok").click( function() {
        //alert("press yes button");
        $.alerts._hide();
        if( callback ) callback(true);
    });
    $("#popup_cancel").click( function() {
        //alert("press no button");
        $.alerts._hide();
        if( callback ) callback(false);
    });
    $("#popup_ok").focus();
break;

我的問題是,每當我嘗試在按鈕單擊上運行此代碼時,它對我來說都很好,並向我詢問是/否選項的問題。 但是,當我嘗試在輸入字段的Enter鍵事件上運行相同的代碼時,它不會向我顯示所需的警報消息,並且始終單擊“是”按鈕,而不會向用戶顯示警報消息。 我無法找到在Button Press事件和Enter key事件下其行為不同的原因。 有任何想法嗎?

輸入鍵也是一個按鈕...所以這是一個..問題是??? 代碼如何知道按鈕是回車鍵?

$("#popup_ok").click(function(event{
    if(event.keycode==13){
         $.alerts._hide();
         if( callback ) callback(true);
    }
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM