Javascript not working

I wanted to make a simple modal from this link but the javascript part is not working. I added the html part in the markdown file ( and made a custom css file which works but the javascript part is not working. I made custom.js file in the theme/js folder and added it to the base.html.twig:

{% do assets.addJs(‘theme://js/special.js’) %}

where have I gone wrong??

That’s not enough information! What happens? There must be a thousand ways this could be “not working”. Your Twig looks fine BTW, I doubt that’s the problem, but you can easily check and report back.

when i click on the modal nothing happens, thats it. It doesn’t open the modal or does anything . I even tried to put alert command but it did not work.

also, you said there could be many problem for it not to work so i made a new pure blank theme, removed all contents and added the css and js file … the css and html part works … but the java again does not work.
I got an error in the browser console

Uncaught TypeError: Cannot set property ‘onclick’ of null

i figured out the solution for this error, but still js is not working. This error means that js file is being loaded and rendered, but then why is the modal not working ?


Try put Your javascript into

   //modal javascript

nope, that did not work. I will put my js file and base.html.twig in a sec.

JS file:

Base html: