Why does my JS not work for this element?

I’m trying to make mdd for this link. I’m able to make the JS for click-to-expand element:
image
One more click

I could not understand why this JS does not work for an element at the end of the html
image
I checked that this element has almost the same html structure as the other ones (for which my JS works). Could you please elaborate on this issue?
cambridge.zip (35.3 KB)

1 个赞

I have not learned JavaScript yet(maybe never will). It seems like the scripts are being executed while the DOM is not ready. To prevent that, you can put script tag(s) at the end of html file, or simply mark them as async.

1 个赞

Thank you so much for enlightening answer :heart_eyes:

1 个赞