td colspan does not work while using jquery show/hide()

后端 未结 9 591
走了就别回头了
走了就别回头了 2021-01-13 16:14

I have a table of content

First Name Last Name Des
9条回答
  •  耶瑟儿~
    2021-01-13 16:47

    The problem is that you are toggling the TR, not the TD within it

    $(this).parent().parent().next()
       1      2         3       4
    
    • 1 is the A

    • 2 is the TD the 1 is in

    • 3 is the TR that 2 is in

    • 4 is the TR below 3

    But your display:none is on the TD within that.

    So I would recommend:

    $("td",$(this).parent().parent().next()).toggle('slow');
    

    where the inner $ will get you the containing TR, and then you use that as context for the "td" selection.

提交回复
热议问题