Reputation: 1043
I have grid row scheme like:
<tr>
<td>110</td>
<td><input class="client-chb" name="checkedRecords" type="checkbox" value="110" title="checkedRecords"></td>
<td>Some name</td>
<td>Some other name</td>
<td>1.1.2012</td>
</tr>
I have one function where I get all selected checkboxes, get their values and send to the server via ajax.
But I want just before I make that ajax post, to get 3 & 4 <td>
and change text style like:
<td><b>Some name</b></td>
I need this vice versa. Or to be more clear, this is "mark as read" and "mark as unread" message inbox.
function MarkAsUnread() {
var idata = new Array();
$(".client-chb:checked").each(function() {
var test = $(this);
// maybe here, test -> find next td -> change text
idata.push($(this).val());
});
//other logic
}
Upvotes: 1
Views: 1407
Reputation: 7100
You have iterating over input elements wrapped within TD, so first you want to et the parent of your input element(checkbox) and the perform next..
Like,
function MarkAsUnread() {
var idata = new Array();
$(".client-chb:checked").each(function() {
var test = $(this).parent();
var next1 = test.next();
var next2 = test.next().next();
idata.push(next1.val());
idata.push(next2.val());
});
//other logic
}
To get or set contents of next and next to next TDs use next1.val() and next2.val()
Upvotes: 0
Reputation: 144719
You can try the following:
function MarkAsUnread() {
var idata = new Array();
$(".client-chb:checked").each(function() {
$(this).closest('tr').find('td').slice(2, 4).wrapInner('<b/>')
idata.push($(this).val());
});
}
Upvotes: 2