Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript setattribute onclick function with parameters


var but = document.createElement('button');

var variable = 'some string';

var but.setAttribute('onclick', 'some_function( " '+ variable +' " )');

// Or to use addEventListener() instead of setAttribute() ?
 
PREVIOUS NEXT
Tagged: #javascript #setattribute #onclick #function #parameters
ADD COMMENT
Topic
Name
2+3 =