JSFiddle - React, Tailwind, and code Playground
HTML
<form id="test">
<input type="text">
<input type="submit" value="submit">
</form>
JavaScript
$(function() {
//create x
function x() {
alert('im from x');
}
//create y that receives the function
function y(callback) {
//bind your handler which calls callback (which was x)
$('#test').submit(function() {
callback();
return false;
});
}
//call y that sends over a reference to x
y(x);
});