JSFiddle - React, Tailwind, and code Playground
HTML
<button id="my_button_id">
Click Me
</button>
JavaScript
//Clousure
(function($) {
//Document.ready
$(function(){
//I think you want this ?
let myparam = { onclick: function() { alert("second"); } };
$('#my_button_id').on('click', function(){ alert('first'); myparam.onclick() });
//Another way.
function doAlert (messages) {
alert(messages);
}
//Params Object
let my_params = {
onclick_first : function () { return doAlert('first') },
onclick_second : function () { return doAlert('second') }
}
//Event Click
$('#my_button_id').on('click',function(){
//First Alert
my_params.onclick_first();
//Second Alert
my_params.onclick_second();
});
});
})(jQuery);