I would like to know how I can tell in my plugin whether the user passed a document fragment or DOM string – or if they passed an actual object. If they are passing in a DOM string or document fragment I need to .appendTo('body')
$('p.my_plugin').myPlugin();
// or
$(object).myPlugin();
// vs
$('<p>My string</p>').myPlugin();
The basic plugin shell
(function($){
var methods = {
init : function(options) {
return this.each(function() {
console.log(this);
....
I haven’t tested this too much, and I’m not sure if it’s valid, but
this.is('*')seems to work.