Dave,
I love the analogy! :o)
My situation is more like:
$("#Oven").find(".ChristmasPies").remove().appendTo("#CoolingRack"); :o)
Only, I didn't know that I had to use .find(). What I've *really* got is two
unorderd lists, and I'm trying to move selected items from one list to the
other. So, if I wrote something like:
$("#ListA").find("li.Selected").remove().appendTo("#ListB");
Given that ListA and ListB are both IDs to a UL tag (<ul id="ListA">) will the appended items automatically be li tags? I hadn't thought about that.
I'll assume I've got this right unless I hear differently.
Thanks Dave! :o)
Chris
Dave Methvin wrote:
I have the need of removing list items from List A and
then adding them to List B. I'm using the .remove()
function to remove the elements from the DOM. The API
says very urgently that the remove() method doesn't
remove the items from the jQuery object, so that I can
use them later.
How exactly do I go about "using them later"?
I think something like this:
$("#listA").find(".chosen").remove().appendTo("#listB");
If you are targeting just one node as the example above, the remove() isn't
needed because the standard DOM appendChild behavior will remove the node
from its old location before putting it in the new location. However,
consider this example:
$("#stove").find(".lumpsOfCoal").remove().appendTo(".stockings");
If you append to multiple targets (e.g., ".stockings" selects multiple
elements) , the original elements are cloned before being appended to each
target so the original elements would stay in their old place unless you
remove()d them. If you're _not sure_ whether .stockings is going to select
multiple nodes, you should use remove() to make sure the .lumpsOfCoal are
removed from the #stove.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/