This question is to know if there are cross-browser compatibility, and if it is really sure always get the attribute value even after it was removed, for example, in these two cases:
var rel = $(this).closest("tr").remove().attr("rel");
or
var $deltr = $(this).closest("tr").remove();
// code using $deltr to store it
var rel = $deltr.attr("rel");
Thanks.
To my understanding, you cannot get the attr after the element has been removed.
Once remove()
d, the element no longer exists in the DOM and cannot be restored (even if assigned to a variable), and is not available to probe its attributes.
In jQuery 1.4 the detach()
method was created to remove an element from the DOM, but still keep it available for restore. But not remove()
.
This jsFiddle allows you to experiment with getting the rel attribute before and after removing the element.
Note that rel=
is an attribute of the anchor <a>
tag, not of a table tr, but I assume you know what you are doing.