Practical – 115 : Create a Simple Program With JavaScript

Practical-115

Program code : 

<!DOCTYPE html>

<html>

<head>

  <title>Welcome ITI Students</title>

  <style>

    body {

      font-family: Arial, sans-serif;

      text-align: center;

      margin-top: 50px;

    }

    button {

      padding: 10px 20px;

      font-size: 18px;

      background-color: #4CAF50;

      color: white;

      border: none;

      border-radius: 8px;

      cursor: pointer;

    }

    #output {

      margin-top: 20px;

      font-size: 20px;

      color: #333;

    }

  </style>

</head>

<body>

  <h1>Welcome to ITI JavaScript Demo</h1>

  <p>Click the button to see the current time:</p>

  <button onclick=”showTime()”>Show Time</button>

  <div id=”output”></div>

  <script>

    function showTime() {

      const now = new Date();

      const timeString = now.toLocaleTimeString();

      document.getElementById(‘output’).innerHTML = “Current Time: ” + timeString;

    }

 </script>

</body>

</html>