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

241
Vistas
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
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