[removed] How to copy all options from one select element to another?

后端 未结 8 1438
有刺的猬
有刺的猬 2020-12-28 15:41

How can I copy all options of one select element to another? Please give me the easiest way, I\'m allergic to looping.

Please help me. Than

8条回答
  •  北海茫月
    2020-12-28 15:58

    Its an older thread but I hope the following helps someone. No loops at all.

    function copyFromMultiselect(srcId,targetId, allFlag){
        if(allFlag){
            $("#"+targetId).append($("#"+srcId).html());
            $("#"+srcId).empty();
        }else{
            $("#"+targetId).append($("#"+tabContentId+" #"+srcId+" option:selected"));
        }
      }
    

提交回复
热议问题