Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda