Skip to content

Instantly share code, notes, and snippets.

@johnny5th
Created January 10, 2013 23:33
Show Gist options
  • Save johnny5th/4506718 to your computer and use it in GitHub Desktop.
Save johnny5th/4506718 to your computer and use it in GitHub Desktop.
A function to append an element to a container, but first check if it is already there.
function moveElement(elem, container) {
var elemobj = $(elem);
var containerobj = $(container);
if(!elemobj.parent().is(container)) // Check if already there
elemobj.appendTo(container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment