There is such a problem.
And the problem is this: we have <input> , we need to wrap it in a <div> , then again in <div> and again in <div> . Then the penultimate <div> cloned and pasted into the last <div> .
In essence, it should come out:
<div class='wrapper'> <div class='info'> <div> <input> </div> </div> <div class='info'> <div> <input> </div> </div> </div> In fact, nothing complicated, but this way does not work:
var $wrapper = $("<div>").addClass("wrapper"); var $wrapper_two = $("<div class='info'><div></div></div>").appendTo($wrapper); $("input").wrap($wrapper); $wrapper_two.clone().appendTo($wrapper); And the width can not find out:
console.log($wrapper.width()); // => 0 To test: http://jsfiddle.net/1w08fhpv/6/