+ 3

Can I add an attribute to the newly created element in Javascript?

In JS i made new button I can add to it attribute onclick? if so , how?

15th Jun 2018, 11:44 AM
Ω-mega
Ω-mega - avatar
2 Respostas
+ 3
Hello, Ω-mega ! .onclick should be set to a function instead of a string. Try elemm.onclick = function() { alert('hello, world'); };
15th Jun 2018, 11:47 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
Thank you
15th Jun 2018, 11:54 AM
Ω-mega
Ω-mega - avatar