Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda