Hallo,
ich möchte die Werte aus den Formular Textfeldern auslesen und versuche das mit serializeArray().
Wenn ich das Array ausgebe ist es immer leer. Hat jemand ein Idee warum?
$( document ).ready(function() {
function getValues(){
// let fields = $(':input').serializeArray();
let fields = $('form > input:text').serializeArray();
console.log('fields', fields); // gibt leeres Array aus
jQuery.each(fields, function( i, field ) {
$( "#results" ).append( field.value + " " );
});
}
$('button').click(getValues);
});
<form id="form_data">
<input type="text" id="ch1" value="">
<label for="ch1">check1</label>
<input type="text" id="ch2">
<label for="ch2">check2</label>
<input type="text" id="ch3">
<label for="ch3">check3</label>
<button type="button">Run</button>
</form>
<p id="results"></p>
Gruß ebody