I started using electronic js to develop a desktop application.
I want to know how to associate a button click event with a javascript function so that I can perform another operation.
I used the below HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Manav Finance</title>
</head>
<body>
<input type="button" onclick="getData()" value="Get Data" />
</body>
<script>
require('./renderer.js')
</script>
</html>
My renderer.js code is as follows:
function getData(){
console.log('Called!!!');
}
But I get an error message:
Untrained ReferenceError: getData not defined in HTMLInputElement.onclick
Am I doing something wrong?
Update
Updated the HTML document and removed the require () method and now it works:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Manav Finance</title>
<script src="renderer.js"></script>
</head>
<body>
<input type="button" id="btnEd" value="Get Data" onclick="getData()" />
</body>
</html>
source
share