1// HTML
2<form id="myForm" name="myForm">
3 <div>
4 <label for="username">Enter name:</label>
5 <input type="text" id="username" name="username">
6 </div>
7 <button type="button" onclick="clickMe()">Click</button>
8</form>
9
10// JS
11function clickMe(){
12 let myForm = document.getElementById('myForm');
13 let formData = new FormData(myForm);
14 console.log(formData.get('username'));
15}