2011-03-01 82 views
1

1.當我使用鍵盤上箭頭應該強調此舉是爲了向上行,如果我按向下箭頭2.如果我使用UPARROW或高光應該移動到下排導航使用鍵盤使用jQuery

下來箭頭隨着CTRL,我應該能夠多選。

在這裏,我已經寫了代碼,如果我一直按向上鍵則繼續選擇和向下箭頭則取消,但我想這樣做如上提到的什麼我 [http://jsfiddle.net/hKZqS/2/]

回答

1
switch(e.which) 
{ 
    // user presses the "a" key 
    case 38: if(!e.ctrlKey) 
       $('tr').removeClass('ui-selected'); 
       $('tr#'+(clickid-1)).attr('class', 'ui-selected'); 
       clickid = clickid-1; 
       break;  
    // user presses the "s" key 
    case 40: if(!e.ctrlKey) 
       $('tr').removeClass('ui-selected'); 
       $('tr#'+(clickid+1)).attr('class', 'ui-selected'); 
       clickid = clickid+1; 
       break; 
} 

您還必須檢查clickid是否> 0和< tr計數。
http://jsfiddle.net/hKZqS/8/