I am trying to make a button ‘thing’ that handles buttons.
I need to have a way to call a user defined function when the button is clicked.
Here is an examples of an element that would be selected as a button:
<section class = 'button' buttonaction = 'aFunction()'></section>
So, when the button is clicked I want it to get the aFunction() value and use it to call that function.
Example:
elem.onclick = function(){
action = this.getAttribute('buttonaction');
action();
}
I know this example is wrong, but I think it conveys what I want to do.
Thanks,
– Michael Mitchell
You could setup your functions something like this:
And just call one of them by name: