Posted on November 4, 2024, 12:02 pm
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Intro</title>
</head>
<body>
<div id="box"></div>
<script>
//alert a message when webpage loads
alert("Welcome to my Webpage");
// save a message in a variabe and alert it
var msg = "This is third alert";
alert(msg);
// print the message in a html element eg div whose id=box
document.getElementById("box").innerHTML = msg;
</script>
</body>
</html>
No replies yet. Be the first to reply!