Javascript 通过';这';提醒
我想在使用class.removeRow在div中“找到”一个按钮后使用alertify.jsJavascript 通过';这';提醒,javascript,jquery,alertify,Javascript,Jquery,Alertify,我想在使用class.removeRow在div中“找到”一个按钮后使用alertify.js $(".removeRow").find("button").click(function(){ alertify.confirm("remove this field?", function (e) { if (e) { // user clicked "ok"
$(".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函数?d'oh!谢谢你,这很有效。哦!谢谢,这很有效。
$(".removeRow").find("button").click(function(){
var temp = this;
alertify.confirm("remove this field?", function (e) {
if (e) {
// user clicked "ok"
$(temp).closest(".agrRow").remove();
}
});
});