JSFiddle - React, Tailwind, and code Playground
by lollero
HTML
<div id="test" data-yay="Data">test</div>
JavaScript
(function($){
$.fn.extend({
//plugin name - animatemenu
myPlugin: function(options) {
var defaults = {
yay: 'Options'
};
var options = $.extend(true, {}, defaults, options);
return this.each(function() {
var o = options;
var oImage = o.image;
var oCaption = o.caption;
var obj = $(this),
objD = obj.data();
if ( typeof objD.yay === "undefined" ) {
alert('undefined')
}
else { alert('not') }
if ( !objD.yay ) { // this one seems to work for both undefined and false.
obj.text( o.yay );
}
else { obj.text( objD.yay ); }
});
}
});
})(jQuery);
$(document).ready(function() {
$('#test').myPlugin();
});