Hello World - First Program in JavaScript
Name of Program - To print Hello World in JavaScript Programs
Text Editor - Notepad, Notepad++, Visual Studio Code, Atom, etc.
Code Input
1. Without the body tag
<html>
<body>
<script type="text/javascript">
document.write("Welcome javatpoint learners");
</script>
</body>
</html>
Code Output
Welcome javatpoint learners
2. Code between the body tag
Code Input
<html>
<body>
<script type="text/javascript">
alert("Hello JavaScript Learner");
</script>
</body>
</html>
3. Code between the head tag
Code Input
<html>
<head>
<script type="text/javascript">
function msg(){
alert("Hello Javatpoint");
}
</script>
</head>
<body>
<p>Welcome to Javascript</p>
<form>
<input type="button" value="click" onclick="msg()"/>
</form>
</body>
</html>
Code Output
Post a Comment