我的Gridview动态生成的table,然后我希望当鼠标移动到第五列上促发一些操作。如$(function () {
    $('table td:eq(4)').mousemove(function () { alert($(this).html()); });
});为什么我的代码只对第一行的第五列有作用!

解决方案 »

  1.   

    table td:eq(4),所以只对第一列有用,
    table td td:eq(4)
      

  2.   

    发错鸟 table tr td:eq(4)
      

  3.   


    不行$(tr).children("td").eq(4) 也试过!都是只有一样的效果
      

  4.   

    我很费解,你为什么不在绑定第五列的时候 元素上加一个mouseover事件呢?然后把this传过去 不是更简单?
      

  5.   

    先遍历tr
    $('table tr').each(function(){
    $(this).find('td:eq(4)').mousemove(function () { alert($(this).html()); });
    })
      

  6.   

    果然是的
    可是为什么我高亮显示行的时候不用遍历呢?
    $(function () { $("tr").mousemove(function () { $(this).addClass("highlight").siblings().removeClass("highlight"); }) });