I am aware, that similar questions have been asked before, but I can't get it to work with those older posts.
I have the following FormGroup from ReactBootstrap
<Form.Group controlId="formGridWeekdays">
<Form.Label>Wochentage</Form.Label>
<Form.Control
style={{ height: "160px" }}
as="select"
multiple
>
<option value={RRule.MO} data-number="1">Montag</option>
<option value={RRule.TU} data-number="2">Dienstag</option>
<option value={RRule.WE} data-number="3">Mittwoch</option>
<option value={RRule.TH} data-number="4">Donnerstag</option>
<option value={RRule.FR} data-number="5">Freitag</option>
<option value={RRule.SA} data-number="6">Samstag</option>
<option value={RRule.SU} data-number="0">Sonntag</option>
</Form.Control>
</Form.Group>
And I want to access the data-number with jQuery like that:
daysOfWeek: $('#formGridWeekdays').attr('data-number'),
But I only get undefined
$('#formGridWeekdays option:selected')and use each function to iterate in which you can access data like$(this).data('number')daysOfWeek: {…} 0: <option value="MO" data-number="1"> 1: <option value="WE" data-number="3"> 2: <option value="FR" data-number="5"> length: 3Is what is being returned if i write the following:$('#formGridWeekdays option:selected').each(function(){ $(this).data('number') })How would I get just an Array instead of an Object with the numbers?