回答編集履歴

1

修正

2017/08/24 19:27

投稿

s8_chu
s8_chu

スコア14731

test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  <script>
42
42
 
43
- var i = 4;
43
+ var i = 4, s = "input[id^=text]";
44
44
 
45
45
  $("#button1").on("click", function () {
46
46
 
@@ -52,11 +52,11 @@
52
52
 
53
53
 
54
54
 
55
- $(document).on("keyup", "[id^=text]", function (e) {
55
+ $(document).on("keyup", s, function (e) {
56
56
 
57
57
  if (e.keyCode === 13) {
58
58
 
59
- $(this).attr("id") === $("input[id^=text]").last().attr("id") ? $(this).prevAll("[id^=text]").last().focus() : $(this).nextAll("input[id^=text]").eq(0).focus();
59
+ $(this).attr("id") === $(s).eq(-1).attr("id") ? $(this).prevAll(s).eq(-1).focus() : $(this).nextAll(s).eq(0).focus();
60
60
 
61
61
  }
62
62