JSFiddle - React, Tailwind, and code Playground

by gabrieleromanato

HTML

<div id="test">Click</div>

JavaScript

var App = {
    test: function(element) {
    
       var question = confirm('Change the background color?');

       if(question) {

           this.change(element);        

       } else {

          return;
       }          
    },
        
    change: function(element) {
        
       $(element).css('background', 'yellow');                
        
    }
};

(function($) {
    
    $.fn.app = App;
    
    
})(jQuery);


$(function() {
    
    $('#test').click(function() {
        
        $(this).app.test(this);
        
    });
    
});