Jquery 中的 GridView 行

发布于 2024-12-29 03:32:36 字数 811 浏览 4 评论 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 函数内获取单击的行。

I have a gridview which has an asp image-button for deleting a row. I implemented a fade effect while the row is being deleted; that's working fine. My problem is the fade effect works always - whether the user has clicked ok or cancel. I want the fade effect only when user has clicked ok for the confirm box. I am stuck. Below is my code for the fade effect.

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;
            }
        }

I know I cannot place the click event inside the function, but I don't know how I can get the clicked row inside the removeRow function.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拍不死你 2025-01-05 03:32:37

谢谢 Adam,它完成了,而不是 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;
      }
  });

无论如何,感谢您表现出您的关心......非常感谢。

Thanks Adam, its done instead of the if condition outside the qquery click event, i put it inside the click event like below

   $(\"#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;
      }
  });

Anyways thanks for showing your concern... thanks a lot.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文