How to reference script in HTML

Maybe it would be easier to apply your advice to my actual problem over here…

https://www.sitepoint.com/community/t/enable-img-when-li-target-is-true/346331/4

I am trying to apply a simple example that I found over at MDN, but have LOTS of questions not knowing any Javascript. And what we are talking about in this thread is one of them.

But maybe talking about my larger goal will give you some context to help?