1 / 3
amogtech
2 / 3
mhk
3 / 3
ccg


<html>
<head>
<title>Adding Function</title>
</head>
<body>
<p id = "demo"></p>
<button type = "button" onclick = "addFun()">+</button>
<script>
var add = (function(){
var counter = 0;
return function(){
counter += 1;
return counter;
}
})();
function addFun(){
document.getElementById("demo").innerHTML = add();
}
document.getElementById("demo").innerHTML = 0;
</script>
</body>
</html>


Share On: