Prev Demo
JavaScript
>
Code In External File
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>JavaScript code in External file</h1> <script> function AlertMe() { alert("I am being called from external JavaScript file"); } </script> <input type="button" id="btnTest" onclick="AlertMe()" value="Click me!" /> <p>Click the button to get the alert.</p> <p><strong>Note:</strong> In this Demo we can not keep the JavaScript code in the external file, so we are keeping the JavaScript code in HTML page itself. <br>You can try by keeping the script code in external JavaScript file in Visual Studio.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output