<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Wizard-JS Example</title> <!-- Include Wizard-JS library --> <link rel="stylesheet" href="main.css"> <style> /* Style for navigation buttons */ .wizard-nav { margin-top: 20px; } </style> </head> <body> <!-- Wizard container --> <div class=""> <form class="wizard wizard-form" method="POST"> <aside class="wizard-content container"> <!-- Step 1: Personal Information --> <div class="wizard-step" data-title="Personal Information"> <h2>Step 1: Personal Information</h2> <label for="name">Name:</label> <input type="text" id="name" name="name" class="required" placeholder="Enter your name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" class="required" placeholder="Enter your email" required> </div> <!-- Step 2: Address --> <div class="wizard-step" data-title="Address"> <h2>Step 2: Address</h2> <label for="address">Address:</label> <input type="text" id="address" name="address" class="required" placeholder="Enter your address" required> <label for="city">City:</label> <input type="text" id="city" name="city" class="required" placeholder="Enter your city" required> </div> </aside> </form> </div> <!-- Navigation buttons --> <div class="wizard-nav"> <button class="wizard-btn prev">Previous</button> <button class="wizard-btn next">Next</button> <button id="btn_append" class="btn btn-secondary update">Add new step</button> <button class="wizard-btn finish" style="display: none;">Submit</button> </div> <!-- Initialize Wizard-JS --> <script src="utils.js"></script> <script> var $_ = new Utils(); </script> <script src="wizard.js"></script> <script> // Configuration options const args = { "wz_class": ".wizard", "wz_nav_style": "button", "wz_button_style": ".wizard-btn", "wz_ori": "horizontal", "buttons": true, "navigation": 'buttons', "finish": "Save!" }; // Create a new Wizard instance const wizard = new Wizard(args); // Initialize the wizard wizard.init(); let wz_class = ".wizard"; let $wz_doc = document.querySelector(wz_class) // $wz_doc.addEventListener("wz.btn.next", function (e) { // alert("Next Step"); // }); $wz_doc.addEventListener("wz.update", function (e) { console.log(`↓ Target ↓`) console.log(e.detail.target) // .wizard console.log(`↓ DOM Elem ↓`) console.log(e.detail.elem) // DOM form#wizard.wizard.horizontal }); // Custom event handler to display a message when the wizard finishes // wizard.on('formSubmit', () => { // alert('Wizard submitted successfully!'); // }); </script> </body> </html>