Is it just me who find the following code intrinsically backwards?
I am using this posting as a reference.
// create the inner div
var $inner = $("<div>inner</div>")
// append it to a new outer div
.appendTo("<div>outer</div>")
// next change the jQuery chain to the "outer" div
.parent()
// append the outer div to the body
.appendTo("body")
// finally, go back to the last destructive command,
// giving us back a pointer to the "inner" div
.end();
My initial approach would have been to grab the body, then append an outer to the body, and then append an inner to the outer.
Approaching it backwards and then jumping around the hierarchy with things like parent ()
just strikes me as a little curious...