0

Can I get element by value in JavaScript? For example I have this input

<input type="radio" class="form-check-input"  value="this_value">

in javascript I can get an element by name and id but how can I by value?

document.getElementById("this_value")
no thanks
  • 63
  • 10

1 Answers1

3

Use an attribute selector

document.querySelector('[value="this_value"]')
user2182349
  • 9,569
  • 3
  • 29
  • 41