I am trying to create a jquery plugin, and I want have the following options:
$.plugin_name(variable)
$(selector).plugin_name(variable)
The first case the plugin would not need to be applied to an element ( it could create one for example) the second case the same plugin will do whatever it does on the element/s selected
My question is: How do I specify inside the plugin this:
if (selector is not given) {
create an element
} else {
( for example) insert variable in elements matching the selector
}