Given the following code in javascript with jQuery:
var inner = $(\'\')
var outer = inner.wrap(\'\')
console.log(inner
.wrap() works also on jQuery objects that do not reference anything in the DOM, like $('').
But you have to properly ask the result. Due to chaining, you only get the original jQuery object, but you have to ask for the newly created elements around it with .parents() to get your expected result.
$('').wrap('').parents()
will give:
notes from the OP
It's was obvious I was not getting it before, but due to the answer and comments from @jfriend00 I became to grasp it. Also I was in doubt if a jQuery object is only a reference to something in the DOM or could be something entirly new.