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

后端 未结 8 1439
有刺的猬
有刺的猬 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 16:01

    use jQuery foreach?

    $("#the-id option").each(function() {
        var val = $(this).val();
        var txt = $(this).html();
        $("the-other-id").append(
            $('').val(val).html(txt);
        );
    });
    

提交回复
热议问题