How to call JavaScript function in an alert box?

JavascriptWeb DevelopmentFront End Technology

To call a JavaScript function in an alert box, you can try to run the following code −

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         function myFunction(warning) {
            alert(warning);
            catchedAlert();
         }
         function catchedAlert() {
            alert('Alert called!');
         }
      </script>
      <button onclick="myFunction('This is an alert box!')">Click me!</button>
   </body>
</html>
raja
Published on 03-Feb-2018 14:10:37
Advertisements