JQuery的关闭事件从表中的行删除类
-
21-09-2019 - |
题
我现在有与包含一个可点击的链接行的表。 当用户点击任何表行jQuery的UI模式对话框弹出窗口了一个链接,我添加一个类被称为“亮点”的点击链接父TR。 我希望能够做的是,当JQuerys UI对话框关闭从该行删除这一类。 是否有任何人知道我能做到这一点?
下面就是我的Load事件看起来像
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
height: 170,
width: 350,
center: false
});
$('.getData').click(function(e) {
getResults($(this).attr('id'));
$(this).parent().parent().addClass("highlight");
$("div#dialog").dialog('open').dialog('option', 'position', [e.clientX, e.clientY]);
return false;
});
});
由于
解决方案
如果你只有一排与类hightlight在所有的时间,你可以这样做:
$("#dialog").dialog({
autoOpen: false,
height: 170,
width: 350,
center: false,
close: function(event, ui) {
$('table .highlight:first').removeClass('highlight');
// A bit faster in theory
}
});
其他提示
也许这样的事情是你在找什么:
$(document).ready(function() {
$("#dialog").dialog({
autoOpen: false,
height: 170,
width: 350,
center: false,
close: function(event, ui) {
$("table tr").removeClass("highlight");
}
});
$('.getData').click(function(e) {
getResults($(this).attr('id'));
$(this).parent().parent().addClass("highlight");
$("div#dialog").dialog('open').dialog('option', 'position', [e.clientX, e.clientY]);
return false;
});
});
如果有比一排与类高亮那么我建议在$('.getData').click...
方法设置全局变量,以便可以从所述close
方法引用它。更
不隶属于 StackOverflow