I'm confused regarding each() and .each()... I think I need to use both, but I'm not sure how...
Basically, I have a series of checkboxes and when they're checked, I want to get the id of the closest table row and add it to an array that I can then serialize and pass to a function.
So, the html looks like this:
<tr id="t1"><td><input type="checkbox" name="did[]" value="232" class="bd" /></td></tr>
<tr id="t2"><td><input type="checkbox" name="did[]" value="234" class="bd" /></td></tr>
<tr id="t3"><td><input type="checkbox" name="did[]" value="676" class="bd" /></td></tr>
<tr><td><button id="tsid" name="tsid" type="button">Send</button></td></tr>
And, when (and if) the checkbox is selected, I want to get the closest tr id and store it in an array:
var trids = []
And then serialize the input data and the trids array...
So far, I only have this:
$('#tsid').click(function() {
//meant to get the values of the selected checkboxes
var myData = $('input[name=did[]]').serialize();
//meant to find and store the closest tr ids in an array...
$('.bd').each(function() {
var trids = $(this).closest("tr").get(0); //and now I'm lost...
});
}