How to remove selected options from multiple select box with Javascript Prototype?
javascript, prototypejs
Solution
To do this with PrototypeJS (as you tagged the question)
$('feed-items-list').select('option:selected').invoke('remove');
This will select elements with the CSS selector `option:selected` within the descendants of `feed-items-list`. Then invoke the specific method of `remove` on that element.
If you just want to unselect the option as Ian mentioned as well
$('feed-items-list').select('option:selected').each(function(i){
i.selected = false;
});
Problem
I have searched quite a bit for the answer to this question, but no satisfactory result found. I have this code: ``` <select name="items[]" size="0" id="feed-items-list" style="width:100%;" multiple=""> <option value="a">a</option> <option value="b">b</option> <option value="c">c</option> </select> ``` How do I remove all the selected options? Thank you!