JSFiddle - React, Tailwind, and code Playground
HTML
<input id="go-1" type="button" value="Button 1" />
<input id="go-2" type="button" value="Button 2" />
<input id="go-3" type="button" value="Button 3" />
JavaScript
// Original Click Handlers
$('#go-1').click(function() {
var go1 = 'go1'
createDialogue(go1);
});
$('#go-2').click(function() {
var go2 = 'go2'
createDialogue(go2);
});
$('#go-3').click(function() {
var go3 = 'go3'
createDialogue(go3);
});
// Function They Go To
function createDialogue(origin) {
// ...
if(origin = 'go1') { go1(); }
if(origin = 'go2') { go2(); }
if(origin = 'go3') { go3(); }
// ...
}
// Each of the 'if' Functions
function go1() {
document.write('go1 is printed<br />');
}
function go2() {
document.write('go2 is printed<br />');
}
function go3() {
document.write('go3 is printed<br />');
}