1<form action="/">
2 <label for="">Whatever you want</label>
3 <input type="text" id='form'>
4 <input type="submit" id="submit">
5</form>
6
7<script>
8 const btn = document.getElementById('form');
9
10 btn.addEventListener('click', (e) => {
11 e.preventDefault(); // disable the refresh on the page when submit
12 const value = document.getElementById('submit').value;
13
14 console.log(value);
15 });
16</script>