The move_to_last
callback shown below has as its net effect to make this
the last one among all its siblings in the DOM (this
is expected to be a DOM element). It does this by first detaching this
from the DOM, and then re-appending it to its original parent.
function move_to_last () {
var n = jQuery(this);
n.parent().append(n.detach());
}
The intended use of this function is something like
jQuery(".someclass").each(move_to_last);
How would one define the function move_to_last_d3
such that the expression
d3.selectAll(".someclass").each(move_to_last_d3);
would have the same effect as that of the previous expression?
I see an append
method in the d3.js
API reference page, but I can't spot anything like detach
. So this question may boil down to what is the d3.js-equivalent of jQuery's detach
method.