0

我想在具有类 .removeRow 的 div 中“找到”一个按钮后使用 alertify.js

  $(".removeRow").find("button").click(function(){
            alertify.confirm("remove this field?", function (e) {
                if (e) {
                    // user clicked "ok"
                    $(this).closest(".agrRow").remove();
                }
            });     
  });

问题是在我调用 alertify 之后,我失去了“this”的值。如何将“this”传递给 alertify 函数?

4

1 回答 1

4
$(".removeRow").find("button").click(function(){
    var temp = this;
    alertify.confirm("remove this field?", function (e) {
        if (e) {
            // user clicked "ok"
            $(temp).closest(".agrRow").remove();
        }
    });     
});
于 2014-10-21T19:10:16.127 回答