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

221
Views
¿Por qué el archivo html no se conecta con el archivo javascript?

Tengo un problema chicos. Intentando escribir código HTML y JS en diferentes archivos y conectarlos. Creo que lo he hecho, pero nada funciona. ¿Cómo se debe hacer? (el nombre del archivo javascript es correcto)

HTML

 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="index.js"> <title>Document</title> </head> <body> <h3>Check password size</h3> <div class="checker"> <input type="password" name="passcode" placeholder="Enter password" ><br><br> <input type="submit" value="check my password!" onclick="checkpassword()"> </div> <p id="message" class="message"></p> </body> </html>

JAVASCRIPT

 function checkpassword(){ var pas=document.getElementsByName('passcode')[0].value; var x=pas.length; document.getElementById("message").innerHTML="Password size is" +" " +x +" " +"characters"; }
about 4 years ago · Santiago Gelvez
3 answers
Answer question

0

Debe usar la siguiente línea para solicitar/importar su javascript.

 <script type="text/javascript" src="index.js"></script>

La forma en que está escribiendo el código es solo para solicitar un archivo css. Para llamar en un idioma diferente, utiliza un código diferente.

about 4 years ago · Santiago Gelvez Report

0

<script src="fileName.js"></script>

Esto se usa para conectar js a html src significa fuente. Una forma más de hacer js en html es usar en html y escribir su código en la etiqueta como

 <script> function checkpassword(){ var pas=document.getElementsByName('passcode')[0].value; var x=pas.length; document.getElementById("message").innerHTML="Password size is" +" " +x +" " +"characters"; } </script>

puede poner este código en html o puede hacer archivos separados

espero haberte ayudado :)

about 4 years ago · Santiago Gelvez Report

0

Debe usar la etiqueta de script para conectar javascript con html

 <script src="yourFile.js"></script>
about 4 years ago · Santiago Gelvez 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!