How to pull a specific Javascript pro HTML function

Asked

Viewed 40 times

-4

I have a website and I am struggling, Javascript codes are all mixed with html because when I put in only 1 file it does not run in html, have to open a tag below each item that has function. I wanted to know: How do I run all the functions of the site without having to open a tag below each item that has a function in js? Detail, I need 1 file for each page or only 1 file with all functions?

  • 3

    You could put the example of a page with html with js ?

  • 1

    Good afternoon. Need a [mcve] on your question.

1 answer

2

Post your code in the next questions

There is a tag <script> You can use it and "pull" the functions of a file using the src

Let’s assume your file is called index.js

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

The src is where the file is coming from, this way you can have multiple functions in a file, or multiple files for each page.

I hope you understand

  • 1

    Thanks, I got it !!

  • After reading this answer I understood the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.