JSFiddle - React, Tailwind, and code Playground
by rhodee
HTML
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="all">
body {height: 100%}
#square {width: 50px; height: 50px; background-color: red;}
</style>
<title>Home</title>
<body>
<div id="square">
</div>
</body>
</html>
JavaScript
//Create a class object
function countMe () {
//privately scoped variables
var elt = document.getElementById("square"),
clickCount = 0;
//priveledged methods
this.countClick = function () {
alert("you clicked me " + countClick + " times!");
};
this.addCount = function() {
clickCount += 1
};
};
//Create an instance of the class
var clickCount = new countMe;
//Add an event listener for clicks
clickCount.addEventListener("click", this.countClick ,false);