gpt4 book ai didi

javascript - 通过 'this' 进行警报

转载 作者:行者123 更新时间:2023-11-28 15:33:01 26 4
gpt4 key购买 nike

我想在 div 中“找到”带有 .removeRow 类的按钮后使用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函数中?

最佳答案

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

关于javascript - 通过 'this' 进行警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26494382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com