我目前正在尝试更新一行的值 - 取决于使用 jQuery 的另一个值的行。
例如:
如果Room Allocation = Pending,则 Edit 和 Cancel 按钮出现在 Actions 下 如果Room Allocation != Pending则按钮 Edit 和 Decline 出现在 Actions 下
我该怎么做呢?
这是我包含的小提琴:http: //jsfiddle.net/S9Gwy/
到目前为止,这是我的代码:
$('.results_tbl').dataTable({
"bPaginate": true,
"bLengthChange": false,
"bFilter": true,
"bSort": true,
"bInfo": false,
"bAutoWidth": true
});
/*====================================
determining whether cancel or decline
button is going to appear depending on
room allocation status
=====================================*/
// find all the booking rows
var bookingRows = $('table tr.booking');
// stash a reference to the row
bookingRows.each(function () {
var row = $(this);
// if you can add a class of 'pending' to the status <td>, this becomes even cleaner and nicer...
// check the contents of the status column
if (row.find('td.status').text().toLowerCase() == 'pending') {
// add a class to the row so the CSS can do its thing...
row.addClass('pending');
}
});