jQuery
has a
change() event that you can subscribe to when a
CheckBox
is checked. For example:
$(".test").change(function() {
alert($(".ptime").val());
alert($("#ptime-text").val());
});
To access multiple TextBox values within rows, you can do something like this:
<table>
<tr>
<td class="td"><input type="text" class="txt"></td>
<td><input type="checkbox" class="chk"></td>
</tr>
<tr>
<td class="td"><input type="text" class="txt"></td>
<td><input type="checkbox" class="chk"></td>
</tr>
<tr>
<td class="td"><input type="text" class="txt"></td>
<td><input type="checkbox" class="chk"></td>
</tr>
</table>
jQuery code:
$(".chk").change(function() {
var $row = $(this).closest("tr")
.find(".td");
var $txtValue = $row.find(".txt").val();
alert($txtValue);
});
The idea is to group your elements (
text
and
checkbox
input) within a
<tr>
element so you can easily reference them by descendants.