问题
I'm working on this website where users can create their own bundles. Basically they have a list of courses and they can pick 5 and create a bundle.
The approach I'm taking is a dropdown list of all courses that then gets cloned on click.
What I'd like to do is disable any previously selected items on the next cloned list.
Is this possible?
Here's my code: http://jsfiddle.net/Y4fLM/
Thanks a lot!
回答1:
You can try this one as well
http://jsfiddle.net/Y4fLM/3/
As with your question it seems may be this could be helpful for you.
回答2:
I had to work on somewhat similar requirement to your's but , instead of dynamically creating the select's I have 3 of them on the page.
Check this FIDDLE .. It might be of help.
回答3:
Is this what you're looking for?
http://jsfiddle.net/VLrpn/
The key code comes right before attaching the new element:
$('.hidden-itemname').each(function(index) {
newElem.children('.hidden-itemname').children('option[value="'+$(this).val()+'"]').remove()
});
来源:https://stackoverflow.com/questions/12730841/jquery-clone-select-disable-previously-selected-options