How to use javascript or jQuery to quickly select a preset of multi-select listbox items?
问题 So say my page has a list of indexes '1,3,4,5,9,12' and a multi-select listbox with 12 items in it. What's a fast way to use javascript to tell the listbox to multi-select all items at those indexes? How would this be done using jQuery? So for example if the user selects the 'caramel' preset associated with the 'candybar' listbox, it will select all the candy bars that have caramel... I think you get the idea. 回答1: This could do the trick: <select id="select" multiple="multiple"> <option