JSFiddle - React, Tailwind, and code Playground
HTML
<div id="d1"></div>
JavaScript
$.fn.plugin = function( options ) {
console.log( $.type( options ) );
if( $.type( options ) == 'string' ) {
// Handle string case (first of above)
}
else if( $.type( options ) == 'object' && options != null ) {
// Handle object case (second of above)
}
else {
// Handle invalid input format
}
};
$("#d1").plugin( new String('test')); //string
$("#d1").plugin('test'); //string
$("#d1").plugin({'key' : 'value'}); //object