<html> <head> <title>forms-javascript</title> </head> <body> <p id="prgrph">form-test</p> <form id="frm"> <label for="input2">Town:</label> <input type="text" name="npt" id="input2" required> <button id="btn">Submit</button> </form> <script> let myArray=[]; document.querySelector("#btn").addEventListener("click",function(e){ e.preventDefault; myArray.push(document.querySelector("#input2").value); document.querySelector("#prgrph").innerText=myArray[0]; }); </script> </body> </html>
var yourArr = $('#input2').map(function() { return $(this).val(); }).get();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)