Why use the set attribute to listen for events. Do this directly using the property onclickas follows:
newSelect.onclick = function() {
add(obj, mal_pat_id, instruction, line);
}
Or better:
newSelect.addEventListener("click", function() {
add(obj, mal_pat_id, instruction, line);
});
Note. This is not available for all attribute types.
source
share