0
Event listener doesn't work [solved]
Event listeners doesn't work when there is any element after paragraph All in code I don't know why they don't work https://code.sololearn.com/WvxrA0GoY5Ty/?ref=app Upd: i replaced div.innerHTML+="<br>" by document.createElement("br") and it works. Idk why, but ok
16 Respuestas
+ 3
I added some comments in the code
https://code.sololearn.com/WE3z9L0YbEDL/?ref=app
+ 1
What is the code supposed to do?
What is "data"?
+ 1
To highlight what I changed in your code. LOOK AT THE CODE
+ 1
Click on paragraph 1, hi1 will be alerted, click paragraph 2, hi2 will be alerted
That means your data functions are attached to the corresponding elements
+ 1
You can add as many <br> as you want.
The breaks are not critical to the functionality, that is why I removed them in the example. You need to adjust your code yourself.
+ 1
In your code, only the click event for the last paragraph works.
I demonstrated how to make the events work.
You need to decide yourself how many line breaks you want and where to put them.
I gave an example, not a solution to whatever task.
0
Lisa this functions is functions which executed when paragraph is clicked. First function for first paragraph, second for secons etc.
0
Lisa okay
But for what?
0
Lisa a you added and removed some comments, right?
0
You changed append to appendChild also, and little changed parametrs for function, but this changes nothinh
0
Lisa yes, it works, but I had shown it in my code (read comments). You just removed the extra <br> but i need to have this <br>.
0
I mean you did something, your code works but your code doesn't give information on actual solving
0
Lisa my tests shows that they are critical. Have br - no functionality. No be - have functionality. I don't know why, so i ask
0
My code have this string: div.innerHTML +="<br>". if i remove it, code will work. But I don't want to remove. So i wanted to make code works with br
I think it is bug which not depends on us code
0
Did you read comments in code? You removed br because it wasn't bad for functionality? But i written that they it was
0
Okay i just don't understand for what did you do that
Your code almost same as mine (except commensts)