I have this code
<div class="signup">
<h2 class="form-title" id="signup"><span>or</span>Sign up</h2>
<div class="form-holder">
<input type="text" class="input" placeholder="Name" />
<input type="email" class="input" placeholder="Email" />
<input type="password" class="input" placeholder="Password" />
</div>
<button onclick="signup(this)" class="submit-btn">Sign up</button>
</div>
<script type="module" src="/libs/ajax.js"></script>
<script type="module" src="/scripts/login.js"></script>
No from the onclick here, I would like to call a function signup that is inside my login.js file
import { Ajax } from '../libs/ajax.js'
let signup = (e) =>{
console.log(e)
}
The problem is, I am using type="module" because I would like to import script within that js file. But, by assigning a type module, the function is not found from the html file. If I remove import and remove type="module" it does work.
Is there a way to bind a function from the onclick without assign my function to window. scope ?
let signup, usefunction signup, functions hoists in javascript, meaning they don't need order of declaration, they are always on top