In my html file when i click button it will call a function in file home.js.
File index.html:
<body>
<button onclick="ShowMyAlert()"></button>
<script src="/js/home.js"></script>
</body>
And the funtion will call another function in file cUtilitiesForm.js. File home.js:
var x = require('./cUtilitiesForm')
function ShowMyAlert() {
x.ShowAlertSuccess('Good job')
}
File cUtilitiesForm.js:
function ShowAlertSuccess(title) {
Swal.fire(
`${title}`,
'success'
)
}
module.exports = {
ShowAlertSuccess: showAlertSuccess,
}
And then I click button it will give a error:
home.js:4 Uncaught TypeError: Cannot read properties of undefined
(reading 'ShowAlertSuccess')
at ShowMyAlert (home.js:4)
at HTMLButtonElement.onclick ((index):52)
I don't know if this is possible or not