Ideally, JavaScript codes should be kept under <head></head>
tag and called from <body>
parts of the page, however JavaScript code can be kept anywhere in the page under <script>
tag.
<!DOCTYPE html> <html> <head> <title>Title</title> <script> function AlertMe() { alert("I am called from JavaScript!"); } </script> </head> <body> <input type="button" id="btnTest" onclick="AlertMe()" value="Click me!" /> </body> </html>
Above code snippet shall show an alert message when “Click me!” button will be clicked.
Views: 5434 | Post Order: 7