I need to create a button in a loop dynamically and attach "onclick" event handler to it and then function for the handler is pre-defined and accepts multiple arguments.
for (var i = 0; .....) {
var b = document.createElement("BUTTON");
b.appendChild(document.createTextNode("fdsfdsfd_" + i));
b.onclick = function() {
var b = getB();
var c = getC();
myFunction(i, b, c);
};
document.appendChild(b);
}
function myFunction(a, b, c) {
}
But when I inspect the thml, there's no "onclick" attribute.
The property innerHTML doesn't fit for my case.