+ 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
1 Odpowiedź
+ 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 😊-->