0

我尝试将用户重定向到另一个页面,但如果他/她单击表格中的 5、8 或最后一个单元格,则不会发生任何事情。第一排没问题。但其他行不起作用。

$("#table td:not(:last-child,:eq(5),:eq(8))").click(function(){
        var url = $(this).parent().find('td:last-child a[title="edit"]').attr('href');          
        if (url != undefined) {
            location.href = $(this).parent().find('td:last-child a[title="edit"]').attr('href');
        }
    }); 
4

1 回答 1

0

使用委托

$("#table").on('click', 'td', function(){
    var $this = $(this);
    if ( $this.index() === 4 || $this.index() === 7 || $this.is(':last-child') ) return;
    var url = $this.nextAll('td:last-child a[title="edit"]').attr('href');          
    if (url != undefined) {
        location.href = $this.nextAll('td:last-child a[title="edit"]').attr('href');
    }
    return false
}); 
于 2013-05-22T14:59:49.693 回答