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

191
Vistas
How to execute JavaScript code when click Button in Webflow

I am newbie in Webflow, In Webflow project I want to get button by id and execute some Javascript code when I click this button.

The code I write:

<script>
    document.addEventListener('DOMContentLoaded', () => {
       let btn = document.getElementById('myButtonId');
       btn.addEventListener('click', () => {
           // handle the click event
           console.log('clicked');
           alert("Hello");
       });
    });
</script>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You'll either need to move the code to the Page Footer,

or wrap the code in the Webflow's recommended "Webflow ready function":

var Webflow = Webflow || {};
Webflow.push(function() {

    // Your code goes here
    document.addEventListener('DOMContentLoaded', () => {
       let btn = document.getElementById('myButtonId');
       btn.addEventListener('click', () => {
          ...
       });
    });

}); // End Webflow ready function
about 4 years ago · Juan Pablo Isaza Denunciar

0

Java script you can call the function any name you want

 <script>
            function yourFunctionName() {
            alert("hello")
            };
        
        </script>

HTML

<body>
    <button id="myButtonId" onclick="yourFunctionName ()">click here</button>
 
</body>
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