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

237
Views
can't call function inside <script> ReactJS

A simple example from w3school:

  <form>
        Select a fruit:
        <select id="mySelect" size="4">
          <option>Apple</option>
          <option>Pear</option>
          <option>Banana</option>
          <option>Orange</option>
        </select>
</form>
  <script type = "text/javascript">
   function myFunction() {
    var x = document.getElementById("mySelect")   <---ERROR on var "Expression expected.ts(1109)"
    x.remove(x.selectedIndex);
   }                                               <---ERROR on }"Unexpected token. Did you mean `{'}'}` or `&rbrace;`?ts(1381)"

  </script>

  <button onclick={myFunction()}>Remove selected fruit</button>

but when i try to implement it I get the errors mentioned above, everything inside the script-tag is also white unless i put it inside curly brackets. I reckon this means the code doesn't complie?

I have tried installing earlier versions of typeScript but with no success.

Any help would be appreciated!

about 4 years ago · Juan Pablo Isaza
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!