I am trying to write a helper function for jQuery that creates an element if it does not already exist. So far, I:
function setup(element, parent){
if($(parent).child(element).length == 0){
$(parent).append('<div class="'+element+'"></div>');
}
}
but I wonder if this is a problem. It?
(The reason I want to is because I can use JSON content and put it in the right place. If the right place exists, I just update the content. If it does not exist, I will create it.)
source
share