0

When passing data to my ejs view i cannot manipulate the dom using the data. when trying to use "inline" code nothing happens, and when trying to use script tag i get an error that the data is not defined.

    function per(data){
        data[1].forEach(el=>{
            document.getElementById(el).checked=true
            
        })
    }
  • As the duplicate suggests, you have client-side code that's supposed to run in the browser and are trying to run it while the template engine processes the template (at which point there's no `document` yet) If you do insert it as ` –  Sep 14 '20 at 18:53
  • Like this for example: https://codesandbox.io/s/tender-snowflake-eqlzp?file=/src/html/index.ejs (I also recommend using pug over ejs, it's vastly superior and more readable imo) –  Sep 14 '20 at 19:02

0 Answers0