Created
January 10, 2013 23:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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