Reputation: 904
I'm trying to get the value of a group of radio buttons in a form. I'm using the code
this.type = form['template-type'].value;
and this works in Chrome and Firefox. However, when I run it in IE 11, it returns undefined
.
I've resorted to the following jQuery code to get the value:
$(form['template-type']).filter(':checked').val()
This code works fine. My question is this: does a native method to get the RadioNodeList value exist in IE11? The MDN article mentions that IE implements the RadioNodeList API, and I can't find any posts about it not working on Google.
Upvotes: 3
Views: 2194
Reputation: 131
I stumbled upon the same issue. It seems that IE11 returns a HtmlCollection
instead of RadioNodeList
, no matter how you select the radio buttons.
Here's a vanilla JS way to get the value of a group of radio buttons. They don't need to be in a form:
document.querySelector('input[name=radioname]:checked').value
Upvotes: 5