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

296
Visualizações
Why can I only use functions from the local script tag in my HTML file?

HTML file

<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, height=device-height">
    <title>
        Hello World!
    </title>
</head>
<body>
    <script type="text/javascript">
        function clickity() {
        document.getElementById('clickity').style.color = 'red';
        alert('this is an alert')
    };
    </script>
    <script type="text/javascript" src="script.js"></script>

    <h1>
        this is a basic webpage
    </h1>
    <p id="clickity" onclick="clickity()" onmouseover="test()">
        Dance 'till you're dead
    </p>
    <div class="tenor-gif-embed" data-postid="13446009" data-share-method="host" data-aspect-ratio="1.15948" data-width="50%" data-height="50%"><a href="https://tenor.com/view/dance-till-you-are-dead-meme-lol-on-yt-dog-gif-13446009">Dance Till You Are Dead Meme GIF</a>from <a href="https://tenor.com/search/dance+till+you+are+dead-gifs">Dance Till You Are Dead GIFs</a></div> <script type="text/javascript" async src="https://tenor.com/embed.js"></script>
</body>

JS file

function test() {
  alert('test');
};

index.js

const { readFile, readFileSync, appendFile } = require('fs');
const express = require('express');
const app = express();

let array = ['this is an array', 'this is array[1]'];

function clickity() {
    document.getElementById('clickity').style.color = 'red';
};
function clackity() {
    alert('clickity clackity');
}

app.get('/', (request, response) => {

    readFile('./home.html', 'utf-8', (err, html) => {
        if (err) {
            response.status(500).send('website go gone');
        }
        response.send(html);
    });

});
console.log(array);
array.push('this is array[2]');// .push() function is the same as .append() in python
console.log(array);

app.listen(process.env.PORT || 3000, () => {console.log('app is running at http://localhost:3000')});
//runs site locally on port 3000

It would seem that I can't use the functions from my JavaScript files, only the ones that are written inside of the tag. The ones in the JS files being imported through the other tags

I also have an improper code to actual words ratio, and I am being yelled at by stack overflow as a result.

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