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

335
Views
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 answers
Answer question

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 Report

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 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!