0

我有一个 gridview,它有一个用于删除一行的 asp 图像按钮。我在删除行时实现了淡入淡出效果;这工作正常。我的问题是淡入淡出效果始终有效-无论用户单击确定还是取消。只有当用户为确认框单击确定时,我才想要淡入淡出效果。我被困住了。下面是我的淡化效果代码。

function removeRow() {
            if (confirm("Are you sure you want to delete this comment?")) {
                $("#dnn_BlogCommentManager1_grdBlogComments td: input[type='image']").click(function () {
                    $tr = $(this).closest("tr");
                    if ($(this).hasClass("imgDelete")) {
                        $tr.css("background-color", "red");
                        $tr.fadeOut(500, function () { $tr.remove() });
                    }
                });
            }
            else {
                return false;
            }
        }

我知道我不能将点击事件放在函数内,但我不知道如何在removeRow函数内获取点击的行。

4

1 回答 1

0

谢谢亚当,它完成而不是qquery点击事件之外的if条件,我把它放在点击事件中,如下所示

   $(\"#dnn_BlogCommentManager1_grdBlogComments td: input[class='imgDelete']\").click(function () {
       $tr = $(this).closest(\"tr\");
  if (confirm(\"Are you sure you want to delete this comment?\")) {
        if ($(this).hasClass(\"imgDelete\")) {
             $tr.css(\"background-color\", \"red\");
              $tr.fadeOut(500, function () { $tr.remove() });
          }
      }
      else {
       return false;
      }
  });

无论如何,感谢您的关注...非常感谢。

于 2012-01-25T20:13:54.307 回答