I have three html buttons on my page:
<button class="timespanbutton" value="1">1</button>
<button class="timespanbutton" value="2">2</button>
<button class="timespanbutton" value="3">3</button>
Now I want to create an array, containing an object for each button:
var timespanObject = {}, timespanArray = [];
countSpecificFacilitySlotAmount = 3;
$('.timespanbutton').each(function() {
slotName = "timespanbutton" + $(this).val();
timespanObject.timespanName = slotName;
timespanArray.push(timespanObject);
});
to get an array containing 3 objects with each created name like
timespanbutton1
timespanbutton2
timespanbutton3
I really do not know, what I am doing wrong, but all three get the name
timespanbutton3
What am I doing wrong?