Jquery 在事件处理中,是否能够将其传递给另一个函数?
单击删除超链接时,将打开一个确认弹出窗口,允许用户做出决定 如果用户单击是,是否可以将此引用传递给是单击事件 简单地说,我的问题是,在yesclick事件处理程序中是否可以使用Jquery 在事件处理中,是否能够将其传递给另一个函数?,jquery,Jquery,单击删除超链接时,将打开一个确认弹出窗口,允许用户做出决定 如果用户单击是,是否可以将此引用传递给是单击事件 简单地说,我的问题是,在yesclick事件处理程序中是否可以使用 var trtext = $(this).closest('tr').text();?? 这是我的密码 $('.delete').on('click', function() { //var trtext = $(this).closest('tr').text(); $("#itemdelpopup
var trtext = $(this).closest('tr').text();??
这是我的密码
$('.delete').on('click', function() {
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("open");
});
$(document).on('click', '#yesclick', function(event) {
alert('clciked on yes');
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("close");
});
$(document).on('click', '#noclick', function(event) {
$("#itemdelpopup").popup("close");
});
例如,我粘贴了一个示例代码,但在我的应用程序中,我使用$(this)做了很多事情,因此不想干扰功能我建议只使用一个变量来跟踪行,如下所示:
var targetRow;
$('.delete').on('click', function() {
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("open");
targetRow = $(this).closest('tr');
});
$(document).on('click', '#yesclick', function(event) {
alert('clciked on yes');
targetRow.remove();
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("close");
});
$(document).on('click', '#noclick', function(event) {
$("#itemdelpopup").popup("close");
});
我建议只使用一个变量来跟踪行,如下所示:
var targetRow;
$('.delete').on('click', function() {
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("open");
targetRow = $(this).closest('tr');
});
$(document).on('click', '#yesclick', function(event) {
alert('clciked on yes');
targetRow.remove();
//var trtext = $(this).closest('tr').text();
$("#itemdelpopup").popup("close");
});
$(document).on('click', '#noclick', function(event) {
$("#itemdelpopup").popup("close");
});