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

234
Visualizações
why doesn't html file connect with javascript file?

I have a problem guys. Trying to write HTML and JS code in different files and connect them. I think I have done it, but nothing works. How it must be done? (javascript file name is correct)

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 Respostas
Responde à pergunta

0

You sould use the following line to call for/import your javascript.

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

The way you are writing the code is only to call for a css file. To call for a different language, you use a different code.

about 4 years ago · Santiago Gelvez Relatório

0

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

This is used to connect js to html src means source One more way to do js in html is by using in html and writing your code in the tag like

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

you can put this code in html or can make seprate files

hope it helped you :)

about 4 years ago · Santiago Gelvez Relatório

0

You need to use the script tag to connect javascript with html

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