<script type="text/javascript">
$(function(){
$(':radio').each(function(){
$(this).bind('click',function(){
alert($(this).val());
});
});
$('tr').bind(function(){
$(this).children(':radio').click();
});
});
</script>
</head><body>
<table cellspacing="1">
<tr>
<th>编号</th>
<th>姓名</th>
</tr>
<tr>
<td><input type="radio" name="sel" id="sel1" /><label for="sel1">1</label></td>
<td>Danie</td>
</tr>
<tr>
<td><input type="radio" name="sel" id="sel2" /><label for="sel2">2</label></td>
<td>Jack</td>
</tr>
<tr>
<td><input type="radio" name="sel" id="sel3" /><label for="sel3">3</label></td>
<td>Tom</td>
</tr>
<tr>
<td><input type="radio" name="sel" id="sel4" /><label for="sel4">4</label></td>
<td>David</td>
</tr>
</table>想实现单击行时,就去点击它其中的radio,为何会提示错误?
tr的click事件中加上这段
        var e = e ? e : window.event;  
        if (window.event) { // IE  
            e.cancelBubble = true;   
        } else { // FF  
            //e.preventDefault();   
            e.stopPropagation();   
        }   也不行。

解决方案 »

  1.   

    你得看看Jquery中绑定事件的时候,最后一个参数是false 还是true
      

  2.   

    你可以这样, 比如:
    $('#myid').click(function(event){
        event.preventDefault();
    })jQuery做了多浏览器支持, 你给个event参数进去, 然后调preventDefault, 在IE下也会执行。(因为实际上这个event变量已经不是那个event变量了)
      

  3.   

    $('#myid').click(function(event){
      event.preventDefault();
    })
    ++阻止泡泡的通用方法,没有浏览器区别!
      

  4.   

    通过使用 stopPropagation() 方法只阻止一个事件起泡。 jQuery 代码:$("form").bind("submit", function(event){
      event.stopPropagation();
    }); 
      

  5.   


    $(function(){
        $(':radio').each(function(){
            $(this).bind('click',function(){
                alert($(this).val());
                 return false;
            });
        });
        $('tr').bind(function(){
            $(this).children(':radio').click(function () {return false;});//return false;阻止冒泡
            
        });
    });
      

  6.   

    <script type="text/javascript">
    $(function(){
        $('tr').bind('click',function(){
        this.children.item(0).children.item(0).click();
       // $(this).children(':radio').click();
           // alert($(this).children(':radio').val());
        });
    $(':radio').bind('click',function(event){
       event.stopPropagation();
       alert($(this).val());
    });
    });
    </script>
    这样可以