Need to clone select box from previous one ( ie, add select box 'n' number of time from the previous one ) But when I added each time, all the previously selected options should not be available in the cloned select box list.
$('.field_select_box_list').each(function(){
$(this).find('option:selected').remove();
});
This code removes the parent select boxes selected option too.. but I want remain them to have the selected option.
any help.
Your clone code can just do something like
$('el').clone().find('option:selected').remove().end()
The .end()
causes the selector to return to being $('el')
rather than the filtered option:selected
selector, so you can continue running things like .appendTo()
etc without needing to break the chain.
I think you need use one select_box original , hidden it. Then you can remove with select_box second not hidden or add more element from select_box original .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.