I have a variable, I created a button that I'll press and change the variable value. How can I perform it?
<html>
<body>
<button>
Button
</button>
<script type="text/javascript">
var a = 0;
</script>
</body>
</html>
add an onclick handler to the button :
<html>
<body>
<button onclick="setA()">
Button
</button>
<script type="text/javascript">
var a = 0;
function setA(){
a=4;
console.log(a);
}
</script>
</body>
</html>