Skip to content

Instantly share code, notes, and snippets.

@JUNKI555
Created May 15, 2019 09:46
Show Gist options
  • Save JUNKI555/60de269c751265554ec9e42e00fa8bb3 to your computer and use it in GitHub Desktop.
Save JUNKI555/60de269c751265554ec9e42e00fa8bb3 to your computer and use it in GitHub Desktop.
20190508_JOBCANのプロジェクト名入力セレクトボックスをvalue順にソートするBookmarklet
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