我有多个与条件选择相关的字段。如果 Condition 与其他输入字段不匹配,则与上述 div ID 中的样式(display:none)和匹配保持活动状态的样式相关联,它在上述 div ID 中设置(display:block)。这是在 drupal 中,所以我不'无法控制它......所以这是生成的示例 -
<div id="edit-field-p1brp-price" class="field-type-text field-name-field-p1brp-price field-widget-text-textfield form-wrapper" style="display: block;">
<div id="field-p1brp-price-add-more-wrapper">
<div class="form-item form-type-textfield form-item-field-p1brp-price-und-0-value">
<label for="edit-field-p1brp-price-und-0-value">
<input id="edit-field-p1brp-price-und-0-value" class="text-full form-text required" type="text" maxlength="255" size="60" value="5,98,000" name="field_p1brp_price[und][0][value]">
</div>
</div>
</div>
<div id="edit-field-sspps-price" class="field-type-text field-name-field-sspps-price field-widget-text-textfield form-wrapper" style="display: none;">
<div id="field-sspps-price-add-more-wrapper">
<div class="form-item form-type-textfield form-item-field-sspps-price-und-0-value">
<label for="edit-field-sspps-price-und-0-value">
<input id="edit-field-sspps-price-und-0-value" class="text-full form-text required" type="text" maxlength="255" size="60" value="4,65,000" name="field_sspps_price[und][0][value]">
</div>
</div>
</div>
<div id="edit-field-sspr1br-price" class="field-type-text field-name-field-sspr1br-price field-widget-text-textfield form-wrapper" style="display: none;">
<div id="field-sspr1br-price-add-more-wrapper">
<div class="form-item form-type-textfield form-item-field-sspr1br-price-und-0-value">
<label for="edit-field-sspr1br-price-und-0-value">
<input id="edit-field-sspr1br-price-und-0-value" class="text-full form-text required" type="text" maxlength="255" size="60" value="3,98,000" name="field_sspr1br_price[und][0][value]">
</div>
</div>
</div>
我必须只获取上面 DIV 中 DISPLAY 为 BLOCK 的那个输入的值。我尝试使用以下可见的 DIV ID,但它没有返回并尝试使用以上 DIV ID 和值也没有发生(这是我尝试的最后一个代码)-
if (($("#edit-field-p1brp-price-und-0-value:block").length > 0)){
var price = $('#edit-field-p1brp-price-und-0-value').val();
}
if (($("#edit-field-sspps-price-und-0-value:visible").length > 0)){
var price = $('#dit-field-sspps-price-und-0-value').val();
}
if (($("#edit-field-sspr1br-price-und-0-value:visible").length > 0)){
var price = $('#edit-field-sspr1br-price-und-0-value').val();
}
更新 - -
我用于获取更改一个选择和警报的值的代码更新,但它只给出 NULL..
$(document).ready(function() {
var price = null;
$('div.form-item-field-membership-payment-type-und').change(function() {
$("#edit-field-p1brp-price-und-0-value, #edit-field-sspps-price-und-0-value, #edit-field-sspr1br-price-und-0-value").each(function() {
if($(this).is(':visible')) {
price = $(this).val();
alert(price);
}
});
alert(price);
});
});