Get array of values from multiple inputs using jQuery/html
It’s not valid to have two inputs of the same name. If you want to do this, you can use
Use Html Below
<input name="titles[]"> <input name="titles[]"> <button>submit</button>
Use JQuery Below
// click handler function onClick(event) { var titles = $('input[name^=titles]').map(function(idx, elem) { return $(elem).val(); }).get(); console.log(titles); event.preventDefault(); } // attach button click listener on dom ready $(function() { $('button').click(onClick); });
Share