N
N
Nekio2021-07-07 11:28:16
JavaScript
Nekio, 2021-07-07 11:28:16

How to get the values ​​of all inputs at once by the date attribute in js?

For example, there is such a layout and by the attribute data-checked="checked" you need to get the value of all inputs

<input class='radio3' type="checkbox" data-checked="checked" value="1-е значение">
<input class='radio3' type="checkbox" data-checked="checked" value="2-е значение">
<input class='radio3' type="checkbox" data-checked="checked" value="3-е значение">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tantumus21, 2021-07-07
@QuayS1de

radios = document.getElementsByClassName('radio3')

for(let i=0; i< radios.length; i++) {
  if(radios[i].getAttribute('data-checked') === 'checked') {
    console.log(radios[i].value)
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question