Taking input from inside handlebar .hbs file

2019-06-03 10:39发布

问题:

I have code inside a .hbs file like this

{{ # each content }}

.....

 <input name = "a" type="text" id="a_id" /> 
 <button onclick="my_fn(a)"> BUTTON </button>
{{/each}}

Inside the code I have defined a button clicking which I want to call

another function:

function my_fn(a){
   alert("Hi"+ a);
}

where "a" is the user input. This way I'm unable to send argument to "my_fn". How this can be done.