in my html, there is a button and it opens chat-bot script.
it perfectly works on html.
but it doesn't work on my script.
...
...
<section>
<button type="button" onclick="javascript:calleoChat('startChat')">Try it</button>
</section>
<script>
//button creation
let btn = document.createElement("button");
btn.innerHTML = "Open Chat-Bot";
//call chat bot script, but it doesn't work
btn.onclick = "javascript:calleoChat('startChat')";
node.appendChild(btn);
//insert button to selected class
document.getElementsByClassName("AddToBagButton__container")[0].appendChild(node);
</script>
please refer my sample codes above, and please give me your kind advice to solve this issue.
onclick="calleoChat('startChat')"
btn.onclick = calleoChat('startChat');
btn.addEventListener("click", () => calleoChat("startChat"));
More info on onclick events: https://www.w3schools.com/jsref/event_onclick.asp