我有函数table.on,现在如果我从表2中删除一个单元格到表1,整个列变绿了
小提琴: http://jsfiddle.net/L3Lhw7jk/5/
tr td:nth-child(2)
整栏变绿,我想把td
放在哪里,而不是整个tr td:nth-child(2)
的CSS:
tr.highlight td {
background-color: #D0ECE7 !important;
}
td.member-highlight {
background-color: #73C6B6 !important;
}
如果出现这种情况:
if (r[0].length > 0) {
$row.parents('table').find('tr').removeClass('highlight');
$row.addClass('highlight');
var members = $('#example tr td:nth-child(2)');
members.filter(':not(:has(input))').addClass('member-highlight');
members.find('input').addClass('border-highlight');
}
var members = $(' #example tr td:nth-child(2)');
使整个栏目中应用整个绿色
table.on('mousedown', 'tbody tr', function() {
var $row = $(this);
var r = table.rows(function(i, data) {
return data.member == $row.children().first().text();
});
if (r[0].length > 0) {
$row.parents('table').find('tr').removeClass('highlight');
$row.addClass('highlight');
var members = $('#example tr td:nth-child(2)');
members.filter(':not(:has(input))').addClass('member-highlight');
members.find('input').addClass('border-highlight');
}
rowCache.push({
row: r
});
});
答案 0 :(得分:1)
您好,请查看此示例worked example
function mouseUp(event) {
var names = $('#example tr td:nth-child(2)');
var ctrl = $(document.elementsFromPoint(event.clientX, event.clientY)).filter('#example tr td:nth-child(2),input.border-highlight');
if (ctrl.length > 0 && rowCache.length > 0) {
var el = rowCache[0];
var data = el.row.data();
if (data.length > 0) {
if (ctrl.is('input'))
ctrl.val(data[0].name);
else
ctrl.text(data[0].name);
el.row.remove().draw();
ctrl.addClass('name-highlight');
//names.removeClass('name-highlight');
names.find('input').removeClass('border-highlight');
}
}
rowCache = [];
}