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

288
Views
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
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!