showing results for - "javascript setattribute onclick function with parameters"
Joaquín
08 Feb 2018
1
2var but = document.createElement('button');
3
4var my_string = '123-45-lol , @%# ';
5
6var but.setAttribute('onclick', 'my_function( " '+my_string+' " )');
7
8// Or to use addEventListener() instead of setAttribute() ?
9