jQuery, Clone select, disable previously selected options

江枫思渺然 提交于 2019-12-25 14:29:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!