Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
button onClick="javascript:calleoChat" works well on Html but not in a script

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. In an onclick you do not need to add "javscript: ", jou can just put the code;

onclick="calleoChat('startChat')"

  1. In the script onclick you do not need to put the script in quotes;

btn.onclick = calleoChat('startChat');

  1. You can also add the event as an eventlistener (this way you can add more):

btn.addEventListener("click", () => calleoChat("startChat"));

More info on onclick events: https://www.w3schools.com/jsref/event_onclick.asp

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!