質問するログイン新規登録

回答編集履歴

4

コメントのミスがありました。

2020/04/23 05:21

投稿

退会済みユーザー
answer CHANGED
@@ -12,7 +12,7 @@
12
12
  (lastItem.val() < targetValue) ? lastItem.after(target) : comparisonInsert(listItems, targetValue);
13
13
 
14
14
  // <li value="103">ううう</li>のvalue値と$('#sortList1 li')全てのvalue値を比較
15
- // <li value="103">ううう</li>のvalue値 > $('#sortList1 li')となった時、その<li>の前に追加
15
+ // $('#sortList1 li')のvalue値 > <li value="103">ううう</li>のvalue値 となった時、その<li>の前に追加
16
16
  function comparisonInsert(list, value) {
17
17
  list.each(function () {
18
18
  if ($(this).val() > value) {

3

引数名がわかりにくかったので変更しました。

2020/04/23 05:21

投稿

退会済みユーザー
answer CHANGED
@@ -13,9 +13,9 @@
13
13
 
14
14
  // <li value="103">ううう</li>のvalue値と$('#sortList1 li')全てのvalue値を比較
15
15
  // <li value="103">ううう</li>のvalue値 > $('#sortList1 li')となった時、その<li>の前に追加
16
- function comparisonInsert(list1, list2) {
16
+ function comparisonInsert(list, value) {
17
- list1.each(function () {
17
+ list.each(function () {
18
- if ($(this).val() > targetValue) {
18
+ if ($(this).val() > value) {
19
19
  $(this).before(target);
20
20
  return false;
21
21
  }

2

1つ前の変更の編集もれです。

2020/04/23 05:17

投稿

退会済みユーザー
answer CHANGED
@@ -9,12 +9,12 @@
9
9
 
10
10
  // <li value="103">ううう</li>のvalue値が$('#sortList1 li')最後尾のvalue値より大きければ一番うしろに追加。
11
11
  // そうでなければ比較処理
12
- (lastItem.val() < targetValue) ? lastItem.after(target) : comparisonInsert(listItems);
12
+ (lastItem.val() < targetValue) ? lastItem.after(target) : comparisonInsert(listItems, targetValue);
13
13
 
14
14
  // <li value="103">ううう</li>のvalue値と$('#sortList1 li')全てのvalue値を比較
15
15
  // <li value="103">ううう</li>のvalue値 > $('#sortList1 li')となった時、その<li>の前に追加
16
- function comparisonInsert(list) {
16
+ function comparisonInsert(list1, list2) {
17
- list.each(function () {
17
+ list1.each(function () {
18
18
  if ($(this).val() > targetValue) {
19
19
  $(this).before(target);
20
20
  return false;

1

関数に引数を渡す形に変更しました。

2020/04/23 05:12

投稿

退会済みユーザー
answer CHANGED
@@ -9,12 +9,12 @@
9
9
 
10
10
  // <li value="103">ううう</li>のvalue値が$('#sortList1 li')最後尾のvalue値より大きければ一番うしろに追加。
11
11
  // そうでなければ比較処理
12
- (lastItem.val() < targetValue) ? lastItem.after(target) : comparisonInsert();
12
+ (lastItem.val() < targetValue) ? lastItem.after(target) : comparisonInsert(listItems);
13
13
 
14
14
  // <li value="103">ううう</li>のvalue値と$('#sortList1 li')全てのvalue値を比較
15
15
  // <li value="103">ううう</li>のvalue値 > $('#sortList1 li')となった時、その<li>の前に追加
16
- function comparisonInsert() {
16
+ function comparisonInsert(list) {
17
- $('#sortList1 li').each(function () {
17
+ list.each(function () {
18
18
  if ($(this).val() > targetValue) {
19
19
  $(this).before(target);
20
20
  return false;