JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output"></div>
JavaScript
var Outside = function () {
this.MyVariable = 'Hi';
this.PersistVariables = 'Oops';
}
Outside.prototype.GenerateHTML = function () {
var that = this;
var localHTML = "<a href='#' id='link' onclick='out.Respond(\"" + that.MyVariable + "\");'>Click Me</a>";
$("#output").html(localHTML);
}
Outside.prototype.Respond = function (whatVariable) {
var that = this;
alert(whatVariable);
alert(that.PersistVariables);
}
var out = new Outside();
$(document).ready(function () {
out.GenerateHTML();
});