I am writing a plugin and have a question. Take these two lines into consideration
$('target').myPlugin();
var myVar = $('target').myPlugin();
Since the second target is not yet in the DOM, there is some functions I would have to change in my plugin to achieve my goals. Yet, those changes may cause the plugin to fail on the first target.
Simply, I am looking for a way (if it is even possible) to determine in my plugin if the target element is already in the DOM or in a variable.
Any help would be appreciated and thank you in advance!
UPDATE
To expound a bit...
Take this example, why does this not work?
var wrapper = $('<div/>');
var newInput = $('<input/>').wrap(wrapper);
$('#newDiv').append(newInput);
Because the input does not actually exist yet...