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

341
Visualizações
Guidance making interactive buttons in JavaScript

I'm new to JavaScript and I am stuck on exactly how to start in my text editor? I've tried googling but I'm getting mixed answers.

I'm trying to make four interactive buttons in a browser. I just don't know how to start? My file is open and the text editor is aware I am using JavaScript.

Now, do I need to start with a script tag? Then what should be the next steps? If anyone could provide me with a little guidance on how I should be thinking in my steps id greatly appreciate it.. Thank you very much

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Start with the Hello World of using a Button HTML tag and script that handles a click event.

For example -- here is the Button defined in HTML.

<button type="submit" class="btn btn-primary btn-xl" id="HelloButton">Say  Hello</button>

Now in a separate JS Script, you can handle the click event:

$(function() {

    $("#HelloButton" ).click(function($e) {

       alert("Say Hello"); 
        
    } );// END of the button click event
 } );

This uses JQUERY as well (in case you want to follow it).

about 4 years ago · Juan Pablo Isaza Relatório

0

Here is a very simple starting page - without using any libraries (like jQuery) or frameworks (like react or vue)

// define the button actions here:

document.querySelectorAll("button").forEach(btn=>btn.onclick=ev=>console.log(`Hey, you have clicked the ${btn.textContent} button!}`));
<button>one</button>
<button>two</button>
<button>three</button>
<button>four</button><br>
<textarea>edit your text here ...
</textarea>

In order for the script to work it needs to run after the page has loaded. In Stackoverflow snippets (see above) that is always the case. However, in your page you need to either put the <script> tag after your <body> element or put it into the callback function of the window.onload() event.

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