JSFiddle - React, Tailwind, and code Playground

by WinKiFlyMe

HTML

<div id="A" style="width:100px;height:100px;background:#163dcc;"></div>
<div id="B" style="width:100px;height:100px;background:#78CC85;"></div>
<div id="AA" style="width:100px;height:100px;background:#ccc78e;"></div>

JavaScript

var test = function (e,name) {
            this.e = e;
            this.name = name;
            this.init();
        };
        test.prototype.init = function () {
            var $e = $(this.e);
            var _this = this;
            $e.click(function () {
                alert(_this.name);
                //show the current name
            });
            $('#AA').click(function () {
                alert(_this.name);
                //show all the name
            })
        };
        new test($("#A"),"A");
        new test($("#B"),"B");