jquery循环每行第一个td

Rip*_*ppo 4 each jquery

我有以下jquery为表中的每个图像添加一个onclick

$("#listtable tr td img").each(
    function(intIndex) {
        $(this).click(function() {
          $(this).load("/Admin/ChangeIdeaStatus/" + $(this).attr('rel'));
        });
    }
);
Run Code Online (Sandbox Code Playgroud)

这工作正常,但是我想修改它,以便只有表中每行的第一个TD中的图像才能获得onclick事件.

我尝试了以下,但它不起作用

$("#listtable tr td:first img").each(
Run Code Online (Sandbox Code Playgroud)

Nic*_*ver 8

试试这个,使用:first-child选择器

$("#listtable tr td:first-child img").click(function() {
  $(this).load("/Admin/ChangeIdeaStatus/" + $(this).attr('rel'));
});
Run Code Online (Sandbox Code Playgroud)