Jeff,

>for (i = $("#mySelect")[0].length - 1; i>=0; i--) {
>  if ($("#mySelect option:selected")[i]) {
>    $("#mySelect").removeOption(i);
>  }
>}

First off, always try to cache jQuery objects if you're planning on reusing
them. This speed things up considerably, as jQuery doesn't have to keep
doing the parsing.

So, in the above example I'd do:

var oSelect = $("#mySelect");

and then reference oSelect when you need it.

With all that said, you should be able what you're wanting in one command:

var oRemoved = $("#mySelect option:selected").remove();

-- or --

var oRemoved = $("#mySelect").remove("option:selected");

That should remove all the selected options. The variable oRemoved should
contain a copy of all the elements that were removed from the DOM--if you
need them.

-Dan

Reply via email to