(function() {
var tasks = /* Some awesome content stored here */
var render = '';
for(var x = 0; x < questions.length; x+= 1) {
render += '<p onclick="changeText(' + x +')">question[i]</p>'
}
function changeText(x) {
// some fancy stuff happens here with a certain x
}
})();
Why do I get the error below when trying to use an IIFE but this works just fine if I get rid of the IIFE? Isn't my changeText() in the same scope as everything else?
How do I fix this?
Uncaught ReferenceError: changeText is not defined
at HTMLElement.onclick