Click Entire Row (preserving middle click and ctrl+click)

后端 未结 10 1154
独厮守ぢ
独厮守ぢ 2020-12-07 20:49

I have an HTML table with a link in the first column. I want to allow the user to click anywhere in the row to activate that link. At the same time, I would like to preser

10条回答
  •  有刺的猬
    2020-12-07 21:25

    you need to remove the < tbody > tag

    and just use the 'href' attribute to get the link destination and dont to select the anchor < a > tag too because thats contains the href attribute.

    $("table#row_link tbody tr a").click(function () {
    
         window.location = $(this).attr("href");
    
    });
    

    or simply make the link open a new tab.

    i hope that helps you.

提交回复
热议问题