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);">
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"]');