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

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