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
  • 43
  • 4

1 Answers1

2

Use an attribute selector

document.querySelector('[value="this_value"]')
user2182349
  • 9,000
  • 3
  • 27
  • 40