Any ideas why this does not work.
The Yes button when clicked works once - the No button does not work
function $(x) {
return document.getElementById(x);
}
var glob = 0;
function new_index() {
glob += 1;
return "d" + glob;
}
function play() {
say("Hello is JS Fun?");
response("No",
function() {
say("Oh dear")
});
response("Yes",
function() {
say("Great:");
});
}
function say(x) {
$("txt").innerHTML += x;
}
function response(Txt, Fun) {
var n = new_index();
var s = "<button id='" + n + "'>" + Txt + "</button>";
say(s);
var xx = $(n);
// xx.onclick=Fun;
xx.addEventListener("click", Fun);
}
play();
<div id="txt"></div>