如何将我的 select2 附加到 div 框?

How can I append my select2 to a div box?

我想将我的 select2 附加到 div box。但后来它不再起作用了。

这里是fiddle:https://jsfiddle.net/r7cop362/165/

<select class="select2" >
    <option selected="selected">Kerry</option>
    <option selected="selected">Cork</option>
</select>
<div id="box"></div>


$('.select2').select2();
$(document).ready(function () {
  $("#box").append("<select class='select2'><option selected='selected'>Cat</option><option selected='selected'>Dog</option></select>");
});

追加后再次调用select2():

$(document).ready(function () {
  $("#box").append("<select class='select2' ><option   selected='selected'>Cat</option><option selected='selected'>Dog</option> </select>");
  $('.select2').select2();
});

UPDATED FIDDLE

在附加 select 标签后初始化 select2 插件。

$(document).ready(function () {
  $("#box").append("<select class='select2' ><option   selected='selected'>Cat</option><option selected='selected'>Dog</option> </select>");
  $('.select2').select2();
});
$("#box").append($('.select2'));

$('.select2').appendTo("#box");