I have a select list into which I place new option elements, and I
want to show them in sorted order. I've searched around and tried some
approaches, but not successful yet.
Here is an example.
It may not be the best use of jQuery, but at least I understand it.
The select element has id ops-memb
I get the current content, then add another option item.
var members = $('#ops-memb').html() + "<option id='507'>Another Item</
option>";
$'#ops-memb').html(members);
This works.
Now I try to sort
$('#ops-memb option').sort(function(a,b) {
return $(a).text() > $(b).text() ? 1 : -1;
});
I get an error message that $('#ops-memb').sort is not a function
Could someone help me understand what I am doing wrong and how to get
this to work correctly?
Thanks.