I've recently created a function that inserts a button inside a leaflet popup, like this:
function popUp(feature, json){
myFunction("Cat").outerHTML
};
Below is the actual function responsible for generating the button:
function myFunction(String) {
button = document.createElement('button');
button.textContent = String
button.onclick = function dog() {
alert("dog");
return false;
};
document.body.appendChild(button);
return button
};
The button shows up and seems clickable in the popup but when clicked, it doesn't trigger any action. I've ensured that pop-ups are enabled in Chrome and even tested it on Firefox, yet the issue persists.
Additionally, these two functions reside within a distinct functions.js file separated from my index.html file.