<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> function che() { alert(); } </script></head><body><form name="rad" method="post" action="#"><div><p><input type="radio" value="1" name="r"/>1</p><p><input type="radio" value="2" name="r"/>2</p></div><input type="button" value="check" onclick="che()"/></form></body></html>
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> function che() { var rs = document.getElementsByName('r'); for (var i = 0, len = rs.length; i < len; i++) { if (rs[i].checked) { alert(rs[i].value); break; } } } </script></head><body><form name="rad" method="post" action="#"><div><p><input type="radio" value="1" name="r"/>1</p><p><input type="radio" value="2" name="r"/>2</p></div><input type="button" value="check" onclick="che()"/></form></body></html>
jquery代码
<script> <br /> $("input[type=radio]").click(function(){ <br /> alert($(this).val()); <br /> }); <br /> </script>
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">