0

I have a drop down list that contains 4 items. I am wanting to grab all of the items from the drop down list and throw them into an array. After that I want to place the 4 items back into the drop down list in a customized order. I have already sorted the list by value, but I need it in a different order than that, so I figured this would be a way to do it?

Can anyone point me in the right direction as to how to pull the items out of drop down list, place in array, then place back in drop down list is specific order?

Here is the code I used to sort by value:

var select = $('select:has(option:contains(Hello))');
var options = select.find("option");
options.sort(function(x, y) {
return x.value < y.value ? -1 : 1;
});
select.empty().append(options);
select.get(0).selectedIndex = 0; 
codeBoy
  • 533
  • 3
  • 7
  • 23

0 Answers0