Attach event listener through javascript to radio button

前端 未结 5 802
春和景丽
春和景丽 2020-12-03 08:13

I have several radio buttons with the same name. Like this:

5条回答
  •  盖世英雄少女心
    2020-12-03 08:48

    A good start, but don't use for..in that way as it will iterate over all enumerable properties and you haven't checked to see if they all represent elements.

    Much better to use an index:

    for (var i=0, iLen=radios.length; i

提交回复
热议问题