jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 我试图从post获取数组的值大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是jQuery的新手,我试图在触发模糊时找到文本框的行ID,但到目前为止我无法使其工作.

当我在第一个文本框中触发blur事件时,我需要的就是form_data中的#employee_0.

$("input").blur(function () {

    $('input').each(function (index,value) {

        var form_data = $("#employee_" + indeX).find('input').serialize();
        $.ajax({
            url: "<?PHP echo site_url("HomeController / calculate_time_lap "); ?>",type: 'POST',data: form_data,success: function (result) {
                $('input').closest('tr').find('.TextBox3').val(result);
            }
        });
        return false;
    });

这是我的观点页面

<tr id="employee_0"><input type ="textBox"></tr>
<tr id="employee_1"><input type ="textBox"></tr>
<tr id="employee_2"><input type ="textBox"></tr>
<tr id="employee_3"><input type ="textBox"></tr>
<tr id="employee_4"><input type ="textBox"></tr>

解决方法

在事件处理程序中,行ID将可用作:

$(this).closest('tr').attr('id');

请注意,您的HTML不合法 – 您需要< td> < tr>内的元素.

相反,如果你只是想找到(并序列化)同一行中的所有输入,你实际上根本不需要ID,你只需从你所在的位置遍历DOM:

$("input").blur(function () {
    var form_data = $(this).closest('tr').find('input').serialize();
    $.ajax(...);
});

大佬总结

以上是大佬教程为你收集整理的jquery – 我试图从post获取数组的值全部内容,希望文章能够帮你解决jquery – 我试图从post获取数组的值所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。