sniperman
07-03-2015, 04:40 PM
I have worked with this pattern with an onclick handler in the HTML and the function in JavaScript.
Is there a more optimized means to fire an event listener / handler which could remove the need for inline HTML JS markup?
I want to pass an incremental unknown value from the input field to a function/constructor, which can take any inputted value.
<label for="gb">Add Stuff</label><input type="button" name="gb" id="gb" onclick="gbDo(this.name, 100)" value="+"></button>
function gbDo(type, amount) {
if(type == "gb")
{
// code here
}
Is there a more optimized means to fire an event listener / handler which could remove the need for inline HTML JS markup?
I want to pass an incremental unknown value from the input field to a function/constructor, which can take any inputted value.
<label for="gb">Add Stuff</label><input type="button" name="gb" id="gb" onclick="gbDo(this.name, 100)" value="+"></button>
function gbDo(type, amount) {
if(type == "gb")
{
// code here
}