we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
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