Home > front end >  I need help for connect js functions with ejs file
I need help for connect js functions with ejs file

Time:12-16

I wonder how I can insert JS functions into an EJS file?

I have this function:enter image description here

I tried to create a separate .ejs file where I will insert a function between the tags <% %> and also import it into the ЕЈS file that I need, but it doesn't work for me

CodePudding user response:

EJS does not provide a DOM. Output from EJS is generated using <%= and similar.

The document object is only (that's a slight simplification) available in JS running in an HTML document in the browser.

To use that code you would need to include it in a <script> element output from the EJS into an HTML document and run in a browser.

  • Related