0

how do I call a function that I have in my html document from my external javascript file?

0

2 Answers 2

5

When the external javascript is included in the page it has access to every function on the page as well as functions in other JS files included on the page.

This is assuming none of the functions are wrapped in a namespace...

Sign up to request clarification or add additional context in comments.

Comments

1

Javascript file:

 function functionName()
    {
    some code to be executed
    }

Html:

<!DOCTYPE html>
<html>
<head>
</head>

<body>
<button onclick="functionName()">Try it</button>
</body>
</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.