回答編集履歴
4
コメントのミスがありました。
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値
|
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
引数名がわかりにくかったので変更しました。
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(
|
16
|
+
function comparisonInsert(list, value) {
|
17
|
-
|
17
|
+
list.each(function () {
|
18
|
-
if ($(this).val() >
|
18
|
+
if ($(this).val() > value) {
|
19
19
|
$(this).before(target);
|
20
20
|
return false;
|
21
21
|
}
|
2
1つ前の変更の編集もれです。
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(
|
16
|
+
function comparisonInsert(list1, list2) {
|
17
|
-
|
17
|
+
list1.each(function () {
|
18
18
|
if ($(this).val() > targetValue) {
|
19
19
|
$(this).before(target);
|
20
20
|
return false;
|
1
関数に引数を渡す形に変更しました。
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
|
-
|
17
|
+
list.each(function () {
|
18
18
|
if ($(this).val() > targetValue) {
|
19
19
|
$(this).before(target);
|
20
20
|
return false;
|