【问题标题】:Select ONLY the very next select box (jQuery)仅选择下一个选择框(jQuery)
【发布时间】:2010-07-17 18:15:20
【问题描述】:

我正在尝试更改当前字段之后的下一个选择框的值。

表单是一长串具有相同类的字段的行。在“第 1 行”中的“数量”字段的焦点上,我想将“类型”选择框更改为同一行中的“框”。我尝试的所有代码都使整个页面上的所有“类型”选择框都发生了变化。我只希望最直接的,最接近数量字段的更改。

UOM 字段是我在用户关注数量时尝试更改的字段。

谢谢!

<tr class="draggable odd">
<td class="content-multigroup-cell-field-part-num">
    <div id="edit-group-order-0-field-part-num-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-part-num-value">J&amp;B No.: 
        </label>
        <input type="text" class="form-text text idleField" value="" size="10" id="edit-group-order-0-field-part-num-value" name="group_order[0][field_part_num][value]" pattern="[0-9]*">
    </div>
</td>
<td class="content-multigroup-cell-field-quantity">
    <div id="edit-group-order-0-field-quantity-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-quantity-value">Quantity: 
        </label>
        <input type="text" class="form-text text idleField" value="" size="5" id="edit-group-order-0-field-quantity-value" name="group_order[0][field_quantity][value]" pattern="[0-9]*">
    </div>
</td>
<td class="content-multigroup-cell-field-quantity-type">
    <div id="edit-group-order-0-field-quantity-type-value-wrapper" class="form-item">
        <label for="edit-group-order-0-field-quantity-type-value">UOM: 
        </label>
        <select id="edit-group-order-0-field-quantity-type-value" class="form-select" name="group_order[0][field_quantity_type][value]">
            <option selected="selected" value="">- None -
            </option>
            <option value="Box(es)">Box(es)
            </option>
            <option value="Case(s)">Case(s)
            </option>
            <option value="Each">Each
            </option>
            <option value="Feet">Feet
            </option>
        </select>
    </div>
</td>

健保编号: 数量: 计量单位: - 没有任何 - 盒子 案例 每个 脚

【问题讨论】:

  • 你能发布你正在使用的当前代码/标记吗?
  • 查看实际的 html 以查看 DOM 层次结构会有所帮助。
  • 我已经用代码更新了原始帖子。很抱歉!

标签: jquery next


【解决方案1】:

我假设您正在使用表格标记并且位于 td 内元素的焦点事件中。

$('input.quantity').focus( function() {
    //get current cell, find nearest select.type in the following siblings
    $(this).parent()
           .nextAll()
           .find('select.type:first').val('boxes');

});

【讨论】:

    【解决方案2】:

    你试过closest吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-17
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多