0
Guys, I’m doing some Javascript tests, and I need to access an IIFE function in the global scope, because the element is being created inside it and it does an execution onclick
calling a function, but this function is within the IIFE scope.
(function(){
function addEle(){
var a = document.createElement('a');
a.setAttribute('href', '#');
a.setAttribute('onclick', 'deleteEle(1)');
a.appendChild(document.createTextNode('Elemento qualquer'));
document.body.appendChild();
}
function deleteEle(pos){
//do....
}
})();
When the user clicks on the button is called the function:
deleteEle()
that is in the local scope and Javascript does not recognize.