jQuery's wrap method
clones the element. The following
uses a cloned version of the container element:
`this.container` is cloned first
When you try to apply the styles after the
fact, those styles are applied to the non-cloned
version that wasn't attached to the DOM.
You can fix this by adding the styles prior to
wrapping the element:
"overflow": "hidden", "backgroundColor": "#CCC"});
Also note that calling remove
doesn't remove anything because only the cloned
container was attached to the DOM. Instead clean
it up by setting it to null.
container = null;
Here is a JSFiddle: http://jsfiddle.net/0db32Lzh/