Here is my Fiddle
Here is my Input Code :
<input type="text" id="first" name="first">
<input type="text" id="second" name="second">
<input type="text" id="third" name="third">
<input type="text" id="fourth" name="fourth">
<input type="button" id="driver" name="driver" value="Submit">
Here is my Script :
<script>
$(document).ready(function() {
$("#driver").click(function(event) {
var A = $("#first").val();
var B = $("#second").val();
var C = $("#third").val();
var D = $("#fourth").val();
console.log(A);
console.log(B);
console.log(C);
console.log(D);
});
});
</script>
There was few fiddle which can create just an array in few complex ways i.e.,
$('document').ready(function() {
var results = [];
var items = $('[name^=item]');
$.each(items, function(index, value) {
value = $(value);
var jsObject = {};
jsObject[value.attr('name')] = value.attr('value');
results.push(jsObject);
});
console.log(results);
});
But Is there a simple way to create an Array with all elements and Extract all the values from the from those Array in JQuery ??