
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to call a function in JavaScript?
JavaScript allows us to write our own functions as well. To invoke a function somewhere later in the script, you would simply need to write the name of that function.
Example
You can try to run the following code to learn how to call a function in JavaScript −
<html> <head> <script> function sayHello() { document.write ("Hello there!"); } </script> </head> <body> <p>Click the following button to call the function</p> <form> <input type = "button" onclick = "sayHello()" value = "Say Hello"> </form> <p>Use different text in write method and then try...</p> </body> </html>
- Related Articles
- How to call a JavaScript function in HTML?
- How to call a Java function inside JavaScript Function?
- How to delay a JavaScript function call using JavaScript?
- How to call a function that returns another function in JavaScript?
- How to call a JavaScript function on click?
- How to call a JavaScript function from C++?
- How to call jQuery function with JavaScript function?
- How to use setInterval function call in JavaScript?
- How to call a JavaScript function on submit form?
- How to call a JavaScript Function from Chrome Console?
- How to turn a String into a JavaScript function call?
- How to call a JavaScript function on a click event?
- JavaScript Function Call
- How to call a function repeatedly every 5 seconds in JavaScript?
- How to call a JavaScript function from an onClick event?

Advertisements