Похожие чаты

Can anyone please tell me what is the correct way

of assigning an event listener to a radio button? I'm using this right now, but it doesn't work as the way I expect.

var el = document.querySelectorAll('input[type=radio][name="score"]');
el.forEach(radio => radio.addEventListener('change', () =>
//somecodes ));

And my html is like:

<input class"..." name="score" value="5" type="radio" />
<input class"..." name="score" value="555" type="radio" />
<input class"..." name="score" value="9999" type="radio" />
<input class"..." name="score" value="0" type="radio" checked="checked" />

Is my code correct?

1 ответов

7 просмотров

radio button is an off/on thing.. what's your purpose?..or what is your expected outcome

Похожие вопросы

Обсуждают сегодня

Карта сайта