【问题标题】:Get control index in jquery在jquery中获取控制索引
【发布时间】:2016-01-03 19:19:56
【问题描述】:

我创建了一个基于 HTML 表格的基本数据网格,每一行都包含许多选择控件。我可以动态添加新的行和控件(作为数组),但似乎无法解决当更改事件触发时如何在 jquery 中获取特定控件的索引。我正在使用

$('#tblGrid').on('change', '.parentClass', function()
    {
    );

我需要使用它来生成行中另一个选择控件的内容(通过 ajax),因为其中的选项取决于第一个控件中的选择

【问题讨论】:

    标签: jquery arrays controls


    【解决方案1】:

    无需查看 html,您可以创建遍历 .... 首先到行...然后在行内使用 find()

    $('#tblGrid').on('change', '.parentClass', function(){
        // `this` inside any event handler is element event occured on
        var $row = $(this).closest('tr');
        var $otherselect = $row.find('.otherSelectClass').doSomething();       
    });
    

    关于其他选择的目标不是很清楚

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      • 2012-04-10
      • 2020-10-14
      • 2021-11-18
      • 2011-02-24
      • 2012-11-07
      相关资源
      最近更新 更多