Positioning a div in js
<p>Wonder if anyone could give me some guidance. I'm trying to reposition a div based on:</p>

<p>if fpd-actions-wrapper has a class of fpd-pos-outside then position in body.
else position (as below) in main wrapper.  </p>

<pre><code>//set action button to specific position
var _setActionButtons = function(pos) {

    fpdInstance.$mainWrapper.append('&lt;div class="fpd-actions-wrapper fpd-pos-'+pos+'"&gt;&lt;/div&gt;');

    var posActions = instance.currentActions[pos];

    for(var i=0; i &lt; posActions.length; ++i) {

        var actionName = posActions[i],
            $action = $actions.children('[data-action="'+actionName+'"]');


        fpdInstance.$mainWrapper.children('.fpd-actions-wrapper.fpd-pos-'+pos).append($action.clone());
    }

};
</code></pre>

<p>I've tried below and it does get .fpd-actions-wrapper out of the main wrapper but it's empty - can't work out the last line.</p>

<pre><code> //set action button to specific position
 var _setActionButtons = function(pos) {
 $body = $('body');
    $body.append('&lt;div class="fpd-actions-wrapper fpd-pos-'+pos+'"&gt;&lt;/div&gt;');

    var posActions = instance.currentActions[pos];

    for(var i=0; i &lt; posActions.length; ++i) {

        var actionName = posActions[i],
            $action = $actions.children('[data-action="'+actionName+'"]');

        fpdInstance.$mainWrapper.children('.fpd-actions-wrapper.fpd-pos- 
        '+pos).append($action.clone());
    }

};
</code></pre>