Created
May 15, 2019 09:46
-
-
Save JUNKI555/60de269c751265554ec9e42e00fa8bb3 to your computer and use it in GitHub Desktop.
20190508_JOBCANのプロジェクト名入力セレクトボックスをvalue順にソートするBookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void((function() { | |
$("[name='projects[]']").each(function(i, obj){ | |
var selectedValue = $(obj).val(); | |
var sortedItems = $(obj).children().sort(function(a,b){ | |
var sortA= a.text; | |
var sortB = b.text; | |
if (sortA > sortB) { | |
return 1; | |
} else if (sortA < sortB) { | |
return -1; | |
} else { | |
return 0; | |
} | |
}); | |
$(obj).empty(); | |
$(obj).append(sortedItems); | |
$(obj).val(selectedValue); | |
}); | |
})()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment