2014-01-09 39 views
-1
 <h:commandLink action="list?faces-redirect=true&amp;includeViewParams=true" 
        id="search">Search 
     </h:commandLink> 
     <h:link outcome="/admin/clients/list.xhtml" styleClass="btn btn-default ml15" id="clear"> 
     Clear 
     </h:link> 

我有以下標籤。當我點擊鏈接頁面剛剛重新加載。 如何使用jquery通過按Alt + Enter在此鏈接上執行該命令?JQuery提交兩個密鑰

+0

您是否嘗試過它呢? – putvande

+0

是的,它使用一個鍵。但有兩個不起作用 – user3127896

+0

你可以編輯你的問題,並添加你試過的嗎? –

回答

0

嘗試:

var cmdLnk = $('#search'); 

$(document).keydown(function(e) { 
    var code = (e.keyCode ? e.keyCode : e.which); 
    if (e.altKey) { 
     if (code === 13) { 
      /* Since 'commandLink' renders as an 'anchor' tag (link) 
      * I assume that you will be able to trigger 'click' event. 
      * However, your question title says to 'submit' with two keys 
      * and, if this is the case, you can replace this last line and 
      * use '$(form).submit()' instead. 
      */ 
      cmdLnk.click(); 
     } 
    } 
}); 

現場演示:http://jsfiddle.net/oscarj24/c5Xgm/