我在使用 parent() 从两个输入框中检索值时遇到问题。和 next() 函数。. 在我看来,这应该有效!谁能看到我错过了什么?
谢谢。
我有这个HTML
<tr>
<td class='headline2' style="width: 200px; padding-bottom: 20px; padding-top:20px; padding-left: 10px; text-align: left;"><?= $value['f_name'] . " " . $value['l_name']; </td>
<td class='headline2'><?= $value[0]->end ?><br><?= $value[0]->start ?></td>
<td class='headline2'style='padding-right:18px;'><?= $value[0]->updated ?></td>
<td><div class="approve"><input disabled <? if ($value[0]->studentApproved == 1) { ?>checked<? } ?> type="checkbox"><label><span></span></label></div></td>
<td><div class="approve"><input disabled <? if ($value[0]->companyApproved == 1) { ?>checked<? } ?> type="checkbox"><label><span></span></label></div></td>
<td><div class="approve"><input class="approveME" value="<?= $value[0]->application_id ?>" <? if ($value[0]->koordinatorApproved == 1) { ?>checked<? } ?> id="<?= $i ?>" type="checkbox"><label for="<?= $i ?>" ><span></span></label></div></td>
<td><input class="deleteME "type="image" src="../wp-content/themes/tutorial_theme/images/DELETE.png"><td>
</tr>
<input class="hidden" value="<?= $value[1] ?>">
<input class="hidden" value="<?= $value[0]->user_id ?>">
而这个JQUERY
$('.content').on('click', '.deleteME', function() {
var class_id = $(this).parent().parent().next().val();
var user_id = $(this).parent().parent().next().next().val();
$.ajax({
type: "POST",
url: (my_ajax_script.ajaxurl),
data: ({action: 'delete_student_from_class', class_id: class_id, student_id: user_id}),
success: function(msg) {
alert("data something" + msg);
}
});
});