DEV Community

Sirb Alin Cristian
Sirb Alin Cristian

Posted on

Simple alert in JavaScript

create html file and write code

<!DOCTYPE html>
<html>
 <head>
  <title>simple alert in javascript</title>
 </head>
 <body>
   <div>
     <button onclick="press()">click here</button>
   </div>
 </body>

 <style>
   div {
    display: flex;
    flex-direction: row;
    justify-content: center;
   }

   button {
    border: 2px solid orange;
    background-color: orange;
    color: #fff;
    font-family: sans-serif;
   }
 </style>

 <script>
   function press() {
     let notification = alert('Congrats!');
   }
 </script>
</html>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)