回答編集履歴
1
sample
answer
CHANGED
@@ -1,1 +1,24 @@
|
|
1
|
-
任意にtabindexを指定して、エンターもそれをエミュレートすればよいのでは?
|
1
|
+
任意にtabindexを指定して、エンターもそれをエミュレートすればよいのでは?
|
2
|
+
|
3
|
+
# sample
|
4
|
+
改めて、こんな感じでどうでしょうか?
|
5
|
+
|
6
|
+
```javascript
|
7
|
+
$(function(){
|
8
|
+
$('input,select').on('keydown',function(e){
|
9
|
+
var flg=e.shiftKey;
|
10
|
+
if(e.keyCode==9 || e.keyCode==13){
|
11
|
+
e.preventDefault();
|
12
|
+
if(flg){
|
13
|
+
var obj=$(this).prevAll('input,select').filter(':visible').first();
|
14
|
+
if(obj.length==0) obj=$(this).siblings('input,select').filter(':visible').last();
|
15
|
+
}else{
|
16
|
+
var obj=$(this).nextAll('input,select').filter(':visible').first();
|
17
|
+
if(obj.length==0) obj=$(this).siblings('input,select').filter(':visible').first();
|
18
|
+
}
|
19
|
+
obj.eq(0).focus();
|
20
|
+
}
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
24
|
+
```
|