0

Normally, when we want to click a radio button automatically on a website, we would use getElementsByName(), getElementbyID(), etc. However, if there is only value that can be use to identify the button, how this can be done?

<input type="radio" name="price" value="123" onclick="changeView(this);">
george
  • 21
  • 5

1 Answers1

1

You can use document.querySelector(). It can take class names, id or even attributes. In your case, it will be

document.querySelector('input[value="123"]');
Hemand S
  • 77
  • 1
  • 5