页面:<script>
$(document).ready(function()
{
  $("#time").change(function(){
  alert("a"); 
  });
});
</script>
<input name="time"  id="time" type="radio" value="6"  checked="checked"> 6个月
<input name="time"  id="time" type="radio" value="12"> 12个月现问:(1)我第一回点击radio按纽时,为什么没反应(不能弹出a)
   (2)现需修改成第一回点击开始,以后每回点击都有反应,如何修改 
thanks

解决方案 »

  1.   

    jquery本身问题。
    可以使用document.getElementById('time').onclick=function(){//code};
      

  2.   

    写错事件关联了,是object.onchange
      

  3.   

    还以为是select控件呢,抱歉。楼上讲的就是原因了,id不唯一引起
      

  4.   

    <script>
    $(document).ready(function()
    {
      $(".time").change(function(){
      alert("a"); 
      });
    });
    </script>
    <input name="time" class="time" type="radio" value="6" checked="checked"> 6个月
    <input name="time" class="time" type="radio" value="12"> 12个月
      

  5.   

    一楼说了
    id 是唯一的 你可以改成class=“time”
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.min.js"></script>
    <script type="text/javascript">
    $(document).ready( function() {
    $(":radio").change( function() {
    alert('aaa');
    });
    /*
    //onchange事件只有在对象的值发生变化时才会触发,如果你要每次点击都有"反应",那就绑定onclick事件
    $(":radio").click( function() { alert('bbb'); });
    */
    });
    </script>
    </head><body>
    <input name="time" id="time1" type="radio" value="6" checked="checked" /> 6个月
    <input name="time" id="time2" type="radio" value="12" /> 12个月
    </body>
    </html>