下面的JS代码通过this变量结合radio按钮的onchange事件快速找出用户选择的哪一个radio按钮
<script> function favAnimal(button) { alert('You like '+button.value+'s.'); } </script> <input type="radio" name="marsupial" value="kangaroo" onchange="favAnimal(this)">Kangaroo <br /><input type="radio" name="marsupial" value="Opossum" onchange="favAnimal(this)">Opossum <br /><input type="radio" name="marsupial" value="Tasmanian Tiger" onchange="favAnimal(this)">Tasmanian Tiger