+ 2

How to pass unique variables to eventsListiner function?

I have a hard time adding events to object and array So: -i created divs using createElement, added the same class using FOR loop and then appendChild to some other html TAG -i want to addEvennt to divs and i want to pass unique variables( i from FOR loop); -it return i max value; or error or does nothing at all THX for any kind of answer :D [Update] code here: https://code.sololearn.com/W03r7gohadV2/?ref=app https://code.sololearn.com/W03r7gohadV2/?ref=app

22nd Nov 2019, 10:02 AM
Antoni Pepe
Antoni Pepe - avatar
1 ответ
+ 1
<!--This is an example--> <!DOCTYPE html> <html> <body> <button id="okay">Let's do it!</button> <div id="nice"></div> <script> document.getElementById("okay").addEventListener("click", function(){ document.getElementById("nice").innerHTML = "Hello World"; }); </script> </body> <!--This might help u 😊-->
22nd Nov 2019, 10:43 AM
VOID
VOID - avatar