I have 2 js files:
utils.js:
class ElementPart
{
constructor(text)
{
this.text = text;
}
}
elem.js
const btn = document.querySelector('.elem_btn');
btn.addEventListener("click", () =>
{
const p = new ElementPart("aaaa");
console.log(p);
})
When I load the page I get the following error:
Uncaught SyntaxError: Unexpected identifier utils.js:1
And when I click on the button:
Uncaught ReferenceError: ElementPart is not defined
at HTMLButtonElement.<anonymous> (elem.js:5)
(anonymous) @ elem.js:5
I load the files on the html file like this:
<script src="/utils.js"></script>
<script src="/createelem.js"></script>